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

© Copyright Housemarque Oy 2002
© Copyright Paul Mensonides 2002

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)