The BOOST_PP_IIF macro chooses between to values based on a bitwise condition.

Usage

BOOST_PP_IIF(bit, t, f)

Arguments

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

Remarks

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

See Also

Requirements

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

Sample Code

#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/logical/or.hpp>

#define OR_IF(p, q, t, f) BOOST_PP_IIF(BOOST_PP_OR(p, q), t, f)

OR_IF(1, 0, abc, xyz) // expands to abc
OR_IF(0, 0, abc, xyz) // expands to xyz

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