P99

◆ P99_IS_EMPTY

#define P99_IS_EMPTY (   ...)
Value:
P00_ISEMPTY( \
/* test if there is just one argument, that might be empty */ \
P99_HAS_COMMA(__VA_ARGS__), \
/* test if P99_IS__EQ__ together with the argument \
adds a comma */ \
P99_HAS_COMMA(P00_IS__EQ__ __VA_ARGS__), \
/* test if the argument together with a parenthesis \
adds a comma */ \
P99_HAS_COMMA(__VA_ARGS__ (/*empty*/)), \
/* test if placing it between P99_IS__EQ__ and the \
parenthesis adds a comma */ \
P99_HAS_COMMA(P00_IS__EQ__ __VA_ARGS__ (/*empty*/)) \
)

Test if the argument list is empty.

This expands to token 1 if the list was empty and to token 0 if there was anything other than a comment in the list.

The implementation of this macro is kind of tricky and relies heavily on the fact that a function macro (P00_IS__EQ__ in this case) is left untouched if it is not followed by a parenthesis. See http://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/

Returns
tokens 0 or 1
Warning
This macro should work for most reasonable invocations (balanced parenthesis and stuff like that). The only case that definitely does not work is when called with another macro X at the end of its argument list, where X itself expects more than one argument. The particular cases where X receives 0, 1 or a variable number of arguments should be fine.

Definition at line 75 of file p99_args.h.

P99_HAS_COMMA
#define P99_HAS_COMMA(...)
Determine of the argument list has a comma, i.e at least two arguments.
Definition: p99_generated.h:165