11 #include <tb_config.h>
19 T Max(
const T& left,
const T& right) {
return left > right ? left : right; }
22 T Min(
const T& left,
const T& right) {
return left < right ? left : right; }
25 T Abs(
const T& value) {
return value < 0 ? -value : value; }
28 T Clamp(
const T& value,
const T& min,
const T& max)
29 {
return (value > max) ? max : ((value < min) ? min : value); }
37 ? (max > min ? max : min)
38 : ((value < min) ? min : value);
43 #define MAX(a, b) Max(a, b)
48 #define MIN(a, b) Min(a, b)
53 #define ABS(value) Abs(value)
58 #define TB_POST_FORMAT(a,b) __attribute__ ((format (printf, a, b)))
61 #define TB_POST_FORMAT(a,b)
66 #define CLAMP(value, min, max) Clamp(value, min, max)
72 #define MAKE_ENUM_FLAG_COMBO(Enum) \
73 inline Enum operator | (Enum a, Enum b) { return static_cast<Enum>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b)); } \
74 inline Enum operator & (Enum a, Enum b) { return static_cast<Enum>(static_cast<uint32_t>(a) & static_cast<uint32_t>(b)); } \
75 inline Enum operator ^ (Enum a, Enum b) { return static_cast<Enum>(static_cast<uint32_t>(a) ^ static_cast<uint32_t>(b)); } \
76 inline void operator |= (Enum &a, Enum b) { a = static_cast<Enum>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b)); } \
77 inline void operator &= (Enum &a, Enum b) { a = static_cast<Enum>(static_cast<uint32_t>(a) & static_cast<uint32_t>(b)); } \
78 inline void operator ^= (Enum &a, Enum b) { a = static_cast<Enum>(static_cast<uint32_t>(a) ^ static_cast<uint32_t>(b)); } \
79 inline Enum operator ~ (Enum a) { return static_cast<Enum>(~static_cast<uint32_t>(a)); }
T ClampClipMax(const T &value, const T &min, const T &max)
Returns value clamped to min and max.
Definition: tb_types.h:34