The BOOST_PP_EXPR_IF macro expands to its second argument if its first argument is non-zero or expands to nothing otherwise.

Usage

BOOST_PP_EXPR_IF(cond, expr)

Arguments

cond
The condition that determines if the result is expr or nothing.  Valid values range from 0 to BOOST_PP_LIMIT_MAG.
expr
The result of the expansion if cond is non-zero.

Remarks

This macro performs a boolean conversion on its first argument.  If that conversion is unnecessary, use BOOST_PP_EXPR_IIF instead.

See Also

Requirements

Header:  <boost/preprocessor/control/expr_if.hpp>

Sample Code

#include <boost/preprocessor/control/expr_if.hpp>
#include <boost/preprocessor/tuple/elem.hpp>

#define CV(n) \
   BOOST_PP_EXPR_IF( \
      n, \
      BOOST_PP_TUPLE_ELEM( \
         4, n, \
         (..., const, volatile, const volatile) \
      ) \
   ) \
   /**/

CV(0) // expands to nothing
CV(1) // expands to const