src/macros.h

changeset 1123
15e46ea3151f
parent 1072
9ce9496427f2
child 1125
d8f94e56d42e
equal deleted inserted replaced
1122:795d1c3554b9 1123:15e46ea3151f
37 #endif // WIN32 37 #endif // WIN32
38 38
39 #define printValueOf(A) dprint ("value of '%1' = %2\n", #A, A) 39 #define printValueOf(A) dprint ("value of '%1' = %2\n", #A, A)
40 #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z})) 40 #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z}))
41 41
42 #define MAKE_ITERABLE_ENUM(T, FIRST, LAST) \ 42 #define MAKE_ITERABLE_ENUM(T) \
43 template<> \ 43 template<> \
44 struct EnumLimits<T> \ 44 struct EnumLimits<T> \
45 {\ 45 {\
46 enum { First = FIRST, Last = LAST, End = LAST + 1, Count = End - FIRST };\ 46 enum { First = 0, Last = static_cast<int>(T::_End) - 1, Count = Last + 1 };\
47 }; \ 47 }; \
48 inline T operator++ (T& a) { a = (T) ((int) a + 1); return a; } \ 48 inline T operator++ (T& a) { a = static_cast<T>(static_cast<int>(a) + 1); return a; } \
49 inline T operator-- (T& a) { a = (T) ((int) a - 1); return a; } \ 49 inline T operator-- (T& a) { a = static_cast<T>(static_cast<int>(a) - 1); return a; } \
50 inline T operator++ (T& a, int) { T result = a; a = (T) ((int) a + 1); return result; } \ 50 inline T operator++ (T& a, int) { T result = a; a = static_cast<T>(static_cast<int>(a) + 1); return result; } \
51 inline T operator-- (T& a, int) { T result = a; a = (T) ((int) a - 1); return result; } 51 inline T operator-- (T& a, int) { T result = a; a = static_cast<T>(static_cast<int>(a) - 1); return result; }
52 52
53 template<typename T> 53 template<typename T>
54 struct EnumLimits {}; 54 struct EnumLimits {};
55 55
56 #define ConfigOption(...) 56 #define ConfigOption(...)

mercurial