1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#pragma once
#include <type_traits>
#include <algorithm>
#include <cmath>
namespace mbgl {
namespace util {
template <typename T>
typename std::enable_if_t<std::is_integral<T>::value, T> max(T a, T b) {
return std::max(a, b);
}
template <typename T>
typename std::enable_if_t<std::is_floating_point<T>::value, T> max(T a, T b) {
return ::fmax(a, b);
}
template <typename T, typename... Ts>
typename std::enable_if_t<std::is_arithmetic<T>::value, T> max(T a, T b, Ts... args) {
return max(a, max(b, args...));
}
template <typename T>
typename std::enable_if_t<std::is_integral<T>::value, T> min(T a, T b) {
return std::min(a, b);
}
template <typename T>
typename std::enable_if_t<std::is_floating_point<T>::value, T> min(T a, T b) {
return ::fmin(a, b);
}
template <typename T, typename... Ts>
typename std::enable_if_t<std::is_arithmetic<T>::value, T> min(T a, T b, Ts... args) {
return min(a, min(b, args...));
}
} // namespace util
} // namespace mbgl
|