The BOOST_PP_EXPR_IIF macro expands to its second argument if its first argument is 1 and expands to nothing if its first argument is 0.

Usage

BOOST_PP_EXPR_IIF(bit, expr)

Arguments

bit
The condition that determines if the result is expr or nothing.  This value must expand to 0 or 1.
expr
The result of the expansion if bit is 1.

Remarks

This macro does not perform a boolean conversion on its first argument.  If that conversion is necessary, use BOOST_PP_EXPR_IF instead.

See Also

Requirements

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

Sample Code

#include <boost/preprocessor/logical/and.hpp>
#include <boost/preprocessor/control/expr_iif.hpp>

#define INSERT_AND(p, q, text) \
   BOOST_PP_EXPR_IIF( \
      BOOST_PP_AND(p, q), \
      text \
   ) \
   /**/

INSERT_AND(2, 3, abc) // expands to abc
INSERT_AND(0, 7, xyz) // expands to nothing

© 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)