Not complicated way to overload MACROS with null,one,two arguments
based on this comment I want to overload one/two arguments and if possible 0 argument, but with minimal rows of macros.
Now I did in the following mode
// For 1..2 arguments, we get 4 rows
#define GET_MACRO(_1,_2, NAME,...) NAME
#define FOO(...) GET_MACRO(__VA_ARGS__, FOO2, FOO1)(__VA_ARGS__)
#define FOO1(x) ABC(F(x))
#define FOO2(x,y) ABC(F(x), F(y))
FOO(x) -> ABC(F(x))
but I have two questions
- is it possible to do this with less then 4 rows ?
is it possible to make overload for 0 arg in the following modeFOO() -> ABC()
Update: 2nd question is not actual any more. So now I have for 0..2 arg - 5 rows. For 1..2 arg - 4 rows. So each additional func_n_arg() need to have separate converter + 2 rows for counting arguments. Is it possible to do with less rows of macros? for the same thing
My four rows is not include 0 arg.
If possible to do the same thing with 3 rows why we should use 4 rows method :) – Alex Blade Jun 23 '19 at 05:39