30 #define RC_NOP(...) __VA_ARGS__
33 #define RC_CAT_HELP(a,b) a ## b
37 #define RC_CAT(a,b) RC_CAT_HELP(a,b)
40 #define RC_EMPTY_CHECK2(a,b,...) b
41 #define RC_EMPTY_CHECKb(...) RC_EMPTY_CHECK2(__VA_ARGS__)
42 #define RC_EMPTY_CHECK(...) RC_EMPTY_CHECKb(__VA_ARGS__ (),0)
43 #define RC_EMPTY_F1RC_EMPTY_F0() ~,1,
44 #define RC_EMPTY_HELP3(a,b,...) a ## b
45 #define RC_EMPTY_HELP2(...) RC_EMPTY_HELP3(RC_EMPTY_F1, __VA_ARGS__ RC_EMPTY_F0)
46 #define RC_EMPTY_HELPb(x,...) RC_EMPTY_CHECK(x)
47 #define RC_EMPTY_HELP(...) RC_EMPTY_HELPb(__VA_ARGS__)
52 #define RC_EMPTY(...) RC_EMPTY_HELP(RC_EMPTY_HELP2(__VA_ARGS__))
56 #define RC_ARGNUMCAT_HELPER(a, b) a ## b
57 #define RC_ARGNUMCAT(a, b) RC_ARGNUMCAT_HELPER(a, b)
58 #define RC_ARGS_NUM_HELPER(_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,_42,_43,_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56,_57,_58,_59,_60,_61,_62,_63,N,...) N
59 #define RC_ARGS_EVAL1(...) 0
60 #define RC_ARGS_EVAL0(...) RC_ARGS_NUM_HELPER(__VA_ARGS__,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1)
65 #define RC_ARGS_NUM(...) RC_ARGNUMCAT(RC_ARGS_EVAL,RC_EMPTY(__VA_ARGS__))(__VA_ARGS__)
69 #define RC_EV(...) RC_EV1(RC_EV1(RC_EV1(RC_EV1(__VA_ARGS__))))
70 #define RC_EV1(...) RC_EV2(RC_EV2(RC_EV2(RC_EV2(__VA_ARGS__))))
71 #define RC_EV2(...) RC_EV3(RC_EV3(RC_EV3(RC_EV3(__VA_ARGS__))))
72 #define RC_EV3(...) RC_EV4(RC_EV4(RC_EV4(RC_EV4(__VA_ARGS__))))
73 #define RC_EV4(...) __VA_ARGS__
75 #define RC_ARGS_EAT(...)
76 #define RC_ARGS_EACH_HELP_1 RC_ARGS_EAT
77 #define RC_ARGS_EACH_HELP_0 RC_ARGS_EACH_LOOP2 RC_ARGS_EAT() ()
78 #define RC_ARGS_EACH_HELP2(x) RC_ARGS_EACH_HELP_##x
79 #define RC_ARGS_EACH_HELP(x) RC_ARGS_EACH_HELP2(x)
80 #define RC_ARGS_EACH_LOOP(func,x,...) func(x)RC_ARGS_EACH_HELP(RC_EMPTY(__VA_ARGS__)) (func,__VA_ARGS__)
81 #define RC_ARGS_EACH_LOOP2() RC_ARGS_EACH_LOOP
87 #define RC_ARGS_EACH(Macro,...) RC_EV(RC_ARGS_EACH_HELP(RC_EMPTY(__VA_ARGS__))(Macro,__VA_ARGS__))
90 #define RC_ARGS_BET_HELP0(func,bet,x,...) func(x)RC_ARGS_EACH(bet func,__VA_ARGS__)
91 #define RC_ARGS_BET_HELP1(func,bet,...)
92 #define RC_ARGS_BET_CAT2(a,b) a##b
93 #define RC_ARGS_BET_CAT(a,b) RC_ARGS_BET_CAT2(a,b)
94 #define RC_ARGS_BET_HELP(func,bet,...) RC_ARGS_BET_CAT(RC_ARGS_BET_HELP,RC_EMPTY(__VA_ARGS__))(func,bet,__VA_ARGS__)
104 #define RC_ARGS_BET(func,bet,...) RC_ARGS_BET_HELP(func,bet,__VA_ARGS__)
107 #define RC_ARGS_LIST_FIRST_1 RC_ARGS_EAT
108 #define RC_ARGS_LIST_FIRST_0 RC_ARGS_LIST_LPFIRST2 RC_ARGS_EAT() ()
109 #define RC_ARGS_LIST_FIRST2(x) RC_ARGS_LIST_FIRST_##x
110 #define RC_ARGS_LIST_FIRST(x) RC_ARGS_LIST_FIRST2(x)
111 #define RC_ARGS_LIST_LPFIRST(func,x,...) func(x)RC_ARGS_LIST_HELP(RC_EMPTY(__VA_ARGS__)) (func,__VA_ARGS__)
112 #define RC_ARGS_LIST_LPFIRST2() RC_ARGS_LIST_LPFIRST
113 #define RC_ARGS_LIST_HELP_1 RC_ARGS_EAT
114 #define RC_ARGS_LIST_HELP_0 RC_ARGS_LIST_LOOP2 RC_ARGS_EAT() ()
115 #define RC_ARGS_LIST_HELP2(x) RC_ARGS_LIST_HELP_##x
116 #define RC_ARGS_LIST_HELP(x) RC_ARGS_LIST_HELP2(x)
117 #define RC_ARGS_LIST_LOOP(func,x,...) ,func(x)RC_ARGS_LIST_HELP(RC_EMPTY(__VA_ARGS__)) (func,__VA_ARGS__)
118 #define RC_ARGS_LIST_LOOP2() RC_ARGS_LIST_LOOP
125 #define RC_ARGS_LIST(func,...) RC_EV(RC_ARGS_LIST_FIRST(RC_EMPTY(__VA_ARGS__))(func,__VA_ARGS__))
128 #define RC_ARGS_PAIR_FIRST_1 RC_ARGS_EAT
129 #define RC_ARGS_PAIR_FIRST_0 RC_ARGS_PAIR_LPFIRST2 RC_ARGS_EAT() ()
130 #define RC_ARGS_PAIR_FIRST2(x) RC_ARGS_PAIR_FIRST_##x
131 #define RC_ARGS_PAIR_FIRST(x) RC_ARGS_PAIR_FIRST2(x)
132 #define RC_ARGS_PAIR_LPFIRST(odd,even,x,y,...) odd(x)even(y)RC_ARGS_PAIR_HELP(RC_EMPTY(__VA_ARGS__)) (odd,even,__VA_ARGS__)
133 #define RC_ARGS_PAIR_LPFIRST2() RC_ARGS_PAIR_LPFIRST
134 #define RC_ARGS_PAIR_HELP_1 RC_ARGS_EAT
135 #define RC_ARGS_PAIR_HELP_0 RC_ARGS_PAIR_LOOP2 RC_ARGS_EAT() ()
136 #define RC_ARGS_PAIR_HELP2(x) RC_ARGS_PAIR_HELP_##x
137 #define RC_ARGS_PAIR_HELP(x) RC_ARGS_PAIR_HELP2(x)
138 #define RC_ARGS_PAIR_LOOP(odd,even,x,y,...) ,odd(x)even(y)RC_ARGS_PAIR_HELP(RC_EMPTY(__VA_ARGS__)) (odd,even,__VA_ARGS__)
139 #define RC_ARGS_PAIR_LOOP2() RC_ARGS_PAIR_LOOP
146 #define RC_ARGS_PAIR(odd,even,...) RC_EV(RC_ARGS_PAIR_FIRST(RC_EMPTY(__VA_ARGS__))(odd,even,__VA_ARGS__))
150 #define RC_ARGS_DECLIST(...) RC_ARGS_PAIR(RC_NOP,RC_NOP,__VA_ARGS__)
153 #define RC_ARGS_PARAMLIST(...) RC_ARGS_PAIR(RC_ARGS_EAT,RC_NOP,__VA_ARGS__)
156 #define RC_DEBOUT_HELP(v) << ", " << #v << " = " << v
167 #define RC_DEBOUT(...) RC_DEBOUT_STREAM << __FILE__ << ":" << __LINE__ RC_ARGS_EACH(RC_DEBOUT_HELP,__VA_ARGS__) << std::endl;
175 #define RC_UNUSED_PARAM(v) v __attribute__((unused))
176 #elif defined(__LCLINT__)
177 #define RC_UNUSED_PARAM(v) v
179 #define RC_UNUSED_PARAM(v) v
197 #define RC_DYNAMIC_LOAD_FUNC_RAW(FuncName,Library) \
198 void* FuncName##_library = dlopen(Library, RTLD_LAZY | RTLD_GLOBAL); \
199 static decltype(&FuncName) FuncName = (FuncName##_library) ? \
200 reinterpret_cast<decltype(FuncName)> \
201 (dlsym(FuncName##_library,#FuncName)): 0;
203 #define RC_DYNAMIC_LOAD_FUNC_RAW(FuncName,Library) \
204 HMODULE FuncName##_library = LoadLibrary(Library); \
205 static decltype(&FuncName) FuncName = (FuncName##_library) ? \
206 reinterpret_cast<decltype(FuncName)> \
207 (GetProcAddress(FuncName##_library,#FuncName)): 0;
212 #define RC_CONSTWRAP_HELP2(Ret,Func,Line,...) \
213 inline Ret Func(RC_ARGS_DECLIST(__VA_ARGS__)) { return RC_CONSTWRAP_Helper__##Line<Ret>(RC_ARGS_PARAMLIST(,*this,__VA_ARGS__)); } \
215 inline const Ret Func(RC_ARGS_DECLIST(__VA_ARGS__)) const { return RC_CONSTWRAP_Helper__##Line<const Ret>(RC_ARGS_PARAMLIST(,*this,__VA_ARGS__)); } \
216 template<class FHRet, class Self> \
218 inline static FHRet RC_CONSTWRAP_Helper__##Line(RC_ARGS_DECLIST(Self&, self, __VA_ARGS__))
219 #define RC_CONSTWRAP_HELP(Ret,Func,Line,...) RC_CONSTWRAP_HELP2(Ret,Func,Line,__VA_ARGS__)
229 #define RC_CONSTWRAP(Ret,Func,...) RC_CONSTWRAP_HELP(Ret,Func,__LINE__,__VA_ARGS__)
234 #define RC_GetTc(T) \
237 inline void Get(T &x) const { x = Get_##T(); }
243 inline void Get(T &x) { x = Get_##T(); }
248 #define RC_DEFAULT_COMPARISON() \
250 template<class AnyValidType> \
251 inline bool operator!= (const AnyValidType& other) const { \
252 return !((*this) == other); \
255 template<class AnyValidType> \
256 inline bool operator> (const AnyValidType& other) const { \
257 return other < (*this); \
260 template<class AnyValidType> \
261 inline bool operator<= (const AnyValidType& other) const { \
262 return !(other < (*this)); \
265 template<class AnyValidType> \
266 inline bool operator>= (const AnyValidType& other) const { \
267 return !((*this) < other); \
272 #define RC_STREAM_RAWWRAP(Type) \
276 inline std::ostream& operator<< (std::ostream &out, Type<T> obj) { \
277 return (out << obj.Raw()); \
283 #define RC_DefaultCopyMove(ClassName) \
285 ClassName(const ClassName&) = default; \
287 ClassName(ClassName&&) = default; \
289 ClassName& operator=(const ClassName&) & = default; \
291 ClassName& operator=(ClassName&&) & = default;
293 #define RC_DefaultCopyMove(ClassName)
299 #define RC_ForIndex(i, cont) for (decltype(cont.size()) i = 0; i < cont.size(); ++i)
305 #define RC_ForEach(e, cont) for(decltype(cont.size()) RC_ForEach_i=0; RC_ForEach_i<cont.size(); ++RC_ForEach_i)if(bool RC_ForEach_b=false);else for(auto&& e=cont[RC_ForEach_i];RC_ForEach_b^=1;)
309 #define RC_ForRange(i, start, past_end) for (decltype(past_end) i = start; i < past_end; ++i)
314 #define RC_Repeat(times) for (decltype(times) RC_Repeat_i = 0; RC_Repeat_i < times; ++RC_Repeat_i)
The version information and configuration settings for RC Lib.
void UnusedVar(const T &)
Mark an unused variable to suppress warnings.
Definition: Macros.h:170