Suppose that I have a macro:
#define FOO(a, ...) if (a) foo(a, ## __VA_ARGS__)
This works well:
FOO(a)
will be transformed toif (a) foo(a)
FOO(a, <some_parameters>)
will be transformed toif (a) foo(a, <some_parameters>)
Is it possible to modify this macro, so only the first parameter of __VA_ARGS__
(if exists) passed to foo
? So, I need:
FOO(a)
to be transformed toif (a) foo(a)
FOO(a, b, <some_parameters>)
to be transformed toif (a) foo(a, b)
I've tried to solve this with the same idea as BOOST_PP_VARIADIC_SIZE
has, but it turned out this macro returns 1
for BOOST_PP_VARIADIC_SIZE()
(empty arguments), which is not expected (I expected 0
).
Note, that I need a solution, where b
and <some_parameters>
are evaluated only when bool(a)
is true
.