src/macros.h

changeset 847
274a7fac44fc
parent 844
11587d419d2f
child 855
e16f1587ef44
equal deleted inserted replaced
846:e4ad109f33c6 847:274a7fac44fc
113 inline T operator++ (T& a) { a = (T) ((int) a + 1); return a; } \ 113 inline T operator++ (T& a) { a = (T) ((int) a + 1); return a; } \
114 inline T operator-- (T& a) { a = (T) ((int) a - 1); return a; } \ 114 inline T operator-- (T& a) { a = (T) ((int) a - 1); return a; } \
115 inline T operator++ (T& a, int) { T result = a; a = (T) ((int) a + 1); return result; } \ 115 inline T operator++ (T& a, int) { T result = a; a = (T) ((int) a + 1); return result; } \
116 inline T operator-- (T& a, int) { T result = a; a = (T) ((int) a - 1); return result; } 116 inline T operator-- (T& a, int) { T result = a; a = (T) ((int) a - 1); return result; }
117 117
118 #define FOR_ENUM_NAME_HELPER(LINE) enum_iterator_ ## LINE
119 #define FOR_ENUM_NAME(LINE) FOR_ENUM_NAME_HELPER(LINE)
120
121 #define for_enum(ENUM, NAME) \
122 for (std::underlying_type<ENUM>::type FOR_ENUM_NAME (__LINE__) = \
123 std::underlying_type<ENUM>::type (ENUM::FirstValue); \
124 FOR_ENUM_NAME (__LINE__) < std::underlying_type<ENUM>::type (ENUM::NumValues); \
125 ++FOR_ENUM_NAME (__LINE__)) \
126 for (ENUM NAME = ENUM (FOR_ENUM_NAME (__LINE__)); NAME != ENUM::NumValues; \
127 NAME = ENUM::NumValues)
128
118 // ============================================================================= 129 // =============================================================================
119 #ifdef IN_IDE_PARSER // KDevelop workarounds: 130 #ifdef IN_IDE_PARSER // KDevelop workarounds:
120 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds) 131 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
121 # define COMPILE_DATE "14-01-10 10:31:09" 132 # define COMPILE_DATE "14-01-10 10:31:09"
122 133

mercurial