Provides a set of convenience macros for metaprogramming and debugging. More...
Go to the source code of this file.
Namespaces | |
RC | |
Macros | |
#define | RC_NOP(...) __VA_ARGS__ |
Evaluates to whatever is passed in. Does no operation. | |
#define | RC_CAT(a, b) RC_CAT_HELP(a,b) |
Concatenates two tokens. | |
#define | RC_EMPTY(...) RC_EMPTY_HELP(RC_EMPTY_HELP2(__VA_ARGS__)) |
Returns 1 if no arguments passed, 0 if arguments are passed. | |
#define | RC_ARGS_NUM(...) RC_ARGNUMCAT(RC_ARGS_EVAL,RC_EMPTY(__VA_ARGS__))(__VA_ARGS__) |
Returns the number of arguments passed to the macro, from 0 to 63. | |
#define | RC_ARGS_EACH(Macro, ...) RC_EV(RC_ARGS_EACH_HELP(RC_EMPTY(__VA_ARGS__))(Macro,__VA_ARGS__)) |
Does RC_ARGS_EACH(Macro,a,b,c) --> Macro(a)Macro(b)Macro(c), for any number of parameters up to 342 or compiler limits. | |
#define | RC_ARGS_BET(func, bet, ...) RC_ARGS_BET_HELP(func,bet,__VA_ARGS__) |
Does RC_ARGS_BET(Func,Between,a,b,c) --> Func(a)Between Func(b)Between Func(c) More... | |
#define | RC_ARGS_LIST(func, ...) RC_EV(RC_ARGS_LIST_FIRST(RC_EMPTY(__VA_ARGS__))(func,__VA_ARGS__)) |
Does RC_ARGS_LIST(Func,a,b,c) --> Func(a),Func(b),Func(c) More... | |
#define | RC_ARGS_PAIR(odd, even, ...) RC_EV(RC_ARGS_PAIR_FIRST(RC_EMPTY(__VA_ARGS__))(odd,even,__VA_ARGS__)) |
Does RC_ARGS_PAIR(Odd,Even,a,b,c,d) --> Odd(a)Even(b),Odd(c)Even(d) More... | |
#define | RC_ARGS_DECLIST(...) RC_ARGS_PAIR(RC_NOP,RC_NOP,__VA_ARGS__) |
Does "RC_ARGS_DECLIST(int,a,int,b)" --> "int a,int b". | |
#define | RC_ARGS_PARAMLIST(...) RC_ARGS_PAIR(RC_ARGS_EAT,RC_NOP,__VA_ARGS__) |
Does "RC_ARGS_PARAMLIST(int,a,int,b)" --> "a,b". | |
#define | RC_DEBOUT(...) RC_DEBOUT_STREAM << __FILE__ << ":" << __LINE__ RC_ARGS_EACH(RC_DEBOUT_HELP,__VA_ARGS__) << std::endl; |
Use RC_DEBOUT(var1, ..., varN) for a flushed stderr debug printout of variables. More... | |
#define | RC_UNUSED_PARAM(v) v __attribute__((unused)) |
Use in function headers as void func(int RC_UNUSED_PARAM(x)) to suppress warnings about non-use. | |
#define | RC_DYNAMIC_LOAD_FUNC_RAW(FuncName, Library) |
Use as RC_DYNAMIC_LOAD_FUNC_RAW(FuncName,Library) to load FuncName from the dynamic library file Library. More... | |
#define | RC_CONSTWRAP(Ret, Func, ...) RC_CONSTWRAP_HELP(Ret,Func,__LINE__,__VA_ARGS__) |
Use to metaprogrammatically generate paired const and non-const getters. More... | |
#define | RC_GetTc(T) |
Generates wrappers for const Get_T functions. More... | |
#define | RC_GetT(T) |
Generates wrappers for Get_T functions. More... | |
#define | RC_DEFAULT_COMPARISON() |
Given == and <, generates !=, >, <=, and >=. More... | |
#define | RC_STREAM_RAWWRAP(Type) |
Provides stream output for a class via Raw. More... | |
#define | RC_DefaultCopyMove(ClassName) |
Provides explicit default copy and move constructors and assignment. More... | |
#define | RC_ForIndex(i, cont) for (decltype(cont.size()) i = 0; i < cont.size(); ++i) |
Creates i of type equivalent to cont.size(), and loops over [0,cont.size). Use like: RC_ForIndex(i, cont) { cout << cont[i]; }. | |
#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;) |
Provides element auto&& e derived from the cont operator[], and loops over [0,cont.size). Like a range-based for loop, but using operator[]. Use like: RC_ForEach(e, cont) { cout << e; }. | |
#define | RC_ForRange(i, start, past_end) for (decltype(past_end) i = start; i < past_end; ++i) |
Creates a for loop over i with type deduction from the past_end. | |
#define | RC_Repeat(times) for (decltype(times) RC_Repeat_i = 0; RC_Repeat_i < times; ++RC_Repeat_i) |
Repeats the following block the specified times, with automatic type deduction. | |
Functions | |
template<class T > | |
void | RC::UnusedVar (const T &) |
Mark an unused variable to suppress warnings. | |
Provides a set of convenience macros for metaprogramming and debugging.
#define RC_ARGS_BET | ( | func, | |
bet, | |||
... | |||
) | RC_ARGS_BET_HELP(func,bet,__VA_ARGS__) |
Does RC_ARGS_BET(Func,Between,a,b,c) --> Func(a)Between Func(b)Between Func(c)
For example: cout RC_ARGS_BET(<< int, << ", ", 1.4, 2.5, 3.6); --> cout << int(1.4) << ", " << int(2.5) << ", " << int(3.5);
#define RC_ARGS_LIST | ( | func, | |
... | |||
) | RC_EV(RC_ARGS_LIST_FIRST(RC_EMPTY(__VA_ARGS__))(func,__VA_ARGS__)) |
Does RC_ARGS_LIST(Func,a,b,c) --> Func(a),Func(b),Func(c)
#define RC_ARGS_PAIR | ( | odd, | |
even, | |||
... | |||
) | RC_EV(RC_ARGS_PAIR_FIRST(RC_EMPTY(__VA_ARGS__))(odd,even,__VA_ARGS__)) |
Does RC_ARGS_PAIR(Odd,Even,a,b,c,d) --> Odd(a)Even(b),Odd(c)Even(d)
#define RC_CONSTWRAP | ( | Ret, | |
Func, | |||
... | |||
) | RC_CONSTWRAP_HELP(Ret,Func,__LINE__,__VA_ARGS__) |
Use to metaprogrammatically generate paired const and non-const getters.
The first parameter is the return type, and the second the function name. Subsequent parameters are pairs of type and variable name for function parameters. Access member variable x with "self.x". E.g.: RC_CONSTWRAP(int&, MyFunc, size_t, index) { return self.array[index]; }
#define RC_DEBOUT | ( | ... | ) | RC_DEBOUT_STREAM << __FILE__ << ":" << __LINE__ RC_ARGS_EACH(RC_DEBOUT_HELP,__VA_ARGS__) << std::endl; |
Use RC_DEBOUT(var1, ..., varN) for a flushed stderr debug printout of variables.
This also prints the file name and line number, and can be used to mark when execution reaches a point with no variables as RC_DEBOUT(). The default destination stream of std::cerr can be changed by defining RC_DEBOUT_STREAM in RCconfig.h or earlier.
#define RC_DEFAULT_COMPARISON | ( | ) |
Given == and <, generates !=, >, <=, and >=.
#define RC_DefaultCopyMove | ( | ClassName | ) |
Provides explicit default copy and move constructors and assignment.
#define RC_DYNAMIC_LOAD_FUNC_RAW | ( | FuncName, | |
Library | |||
) |
Use as RC_DYNAMIC_LOAD_FUNC_RAW(FuncName,Library) to load FuncName from the dynamic library file Library.
This creates a static function pointer named FuncName in-place to provide access to the loaded library. As it overrides FuncName, the previous declaration of FuncName MUST be in an outer scope (outside of the function where this is called). For example, include the original definition from a header, and use this inside of a function or namespace. After this macro, call FuncName with the same syntax as you would the previously declared FuncName. This macro is defined for both Linux and Windows. In the event of an error, FuncName is null. This must be checked in the current version of this macro. A safer version with exception throws is RC_DYNAMIC_LOAD_FUNC.
#define RC_GetT | ( | T | ) |
Generates wrappers for Get_T functions.
#define RC_GetTc | ( | T | ) |
Generates wrappers for const Get_T functions.
#define RC_STREAM_RAWWRAP | ( | Type | ) |
Provides stream output for a class via Raw.