Conditionals

CORE_PP_BOOL(x)

Expands to 1 if the given argument is not false, 0 otherwise.

CORE_PP_BOOL(0)   // 0
CORE_PP_BOOL(1)   // 1
CORE_PP_BOOL(123) // 1

CORE_PP_NOT(x)

Expands to 0 if the given arguemnt is not false, 1 otherwise.

CORE_PP_NOT(0)   // 1
CORE_PP_NOT(1)   // 0
CORE_PP_NOT(123) // 0

CORE_PP_IF(c)

Expands to either a macro that returns its arguments (if the given condition is true) or a macro that returns nothing (if the given condition is false). When invoked with with two pairs of parentheses, this acts much like a traditional if statement: CODE_PP_IF(condition)(then-clause)

CORE_PP_IF(123)(true) // true
CORE_PP_IF(0)(true)   // 

CORE_PP_IF_ELSE(c)

Expands to either a macro that returns its first argument (if the given condition is true) or a macro that return its second argument (if the given condition is false). When invoked with two pairs of parentheses, this works much like a traditional if-then-else statement: CODE_PP_IF_ELSE(condition)(then-clause,else-clause).

CORE_PP_IF_ELSE(123)(true,false) // true
CORE_PP_IF_ELSE(0)(true,false)   // false