Fix macros for overloaded comparisons
This commit is contained in:
parent
86e0b9eb05
commit
1803c27afb
@ -103,14 +103,14 @@
|
|||||||
|
|
||||||
// C++11 solution that is standards compliant.
|
// C++11 solution that is standards compliant.
|
||||||
template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) {
|
template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) {
|
||||||
if (v < n) v = n;
|
if (n > v) v = n;
|
||||||
}
|
}
|
||||||
template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) {
|
template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) {
|
||||||
if (v > n) v = n;
|
if (n < v) v = n;
|
||||||
}
|
}
|
||||||
template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
|
template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
|
||||||
if (v < n1) v = n1;
|
if (n1 > v) v = n1;
|
||||||
else if (v > n2) v = n2;
|
else if (n2 < v) v = n2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -120,21 +120,21 @@
|
|||||||
#define NOLESS(v, n) \
|
#define NOLESS(v, n) \
|
||||||
do{ \
|
do{ \
|
||||||
__typeof__(n) _n = (n); \
|
__typeof__(n) _n = (n); \
|
||||||
if (v < _n) v = _n; \
|
if (_n > v) v = _n; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define NOMORE(v, n) \
|
#define NOMORE(v, n) \
|
||||||
do{ \
|
do{ \
|
||||||
__typeof__(n) _n = (n); \
|
__typeof__(n) _n = (n); \
|
||||||
if (v > _n) v = _n; \
|
if (_n < v) v = _n; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define LIMIT(v, n1, n2) \
|
#define LIMIT(v, n1, n2) \
|
||||||
do{ \
|
do{ \
|
||||||
__typeof__(n1) _n1 = (n1); \
|
__typeof__(n1) _n1 = (n1); \
|
||||||
__typeof__(n2) _n2 = (n2); \
|
__typeof__(n2) _n2 = (n2); \
|
||||||
if (v < _n1) v = _n1; \
|
if (_n1 > v) v = _n1; \
|
||||||
else if (v > _n2) v = _n2; \
|
else if (_n2 < v) v = _n2; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user