blob: 23835a2c4becf6e152650aa75270c8bba47b8c79 [file] [log] [blame]
Brian Silvermanf27e0852018-08-04 23:56:45 -07001<html>
2<head>
3 <title>BOOST_PP_EXPR_IF</title>
4 <link rel="stylesheet" type="text/css" href="../styles.css">
5</head>
6<body>
7 <div style="margin-left: 0px;">
8 The <b>BOOST_PP_EXPR_IF</b> macro expands to its second argument if its first argument is non-zero or expands to nothing otherwise.
9 </div>
10 <h4>Usage</h4>
11 <div class="code">
12 <b>BOOST_PP_EXPR_IF</b>(<i>cond</i>, <i>expr</i>)
13 </div>
14 <h4>Arguments</h4>
15 <dl>
16 <dt>cond</dt>
17 <dd>
18 The condition that determines if the result is <i>expr</i> or nothing.&nbsp;
19 Valid values range from <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.
20 </dd>
21 <dt>expr</dt>
22 <dd>
23 The result of the expansion if <i>cond</i> is non-zero.
24 </dd>
25 </dl>
26 <h4>Remarks</h4>
27 <div>
28 This macro performs a boolean conversion on its first argument.&nbsp;
29 If that conversion is unnecessary, use <b>BOOST_PP_EXPR_IIF</b> instead.
30 </div>
31 <h4>See Also</h4>
32 <ul>
33 <li><a href="expr_iif.html">BOOST_PP_EXPR_IIF</a></li>
34 <li><a href="limit_mag.html">BOOST_PP_LIMIT_MAG</a></li>
35 </ul>
36 <h4>Requirements</h4>
37 <div>
38 <b>Header:</b> &nbsp;<a href="../headers/control/expr_if.html">&lt;boost/preprocessor/control/expr_if.hpp&gt;</a>
39 </div>
40 <h4>Sample Code</h4>
41<div><pre>
42#include &lt;<a href="../headers/control/expr_if.html">boost/preprocessor/control/expr_if.hpp</a>&gt;
43#include &lt;<a href="../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp</a>&gt;
44
45#define CV(n) \
46 <a href="expr_if.html">BOOST_PP_EXPR_IF</a>( \
47 n, \
48 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>( \
49 4, n, \
50 (..., const, volatile, const volatile) \
51 ) \
52 ) \
53 /**/
54
55CV(0) // expands to nothing
56CV(1) // expands to const
57</pre></div>
58 <hr size="1">
59 <div style="margin-left: 0px;">
60 <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
61 </br><i>© Copyright Paul Mensonides 2002</i>
62 </div>
63 <div style="margin-left: 0px;">
64 <p><small>Distributed under the Boost Software License, Version 1.0. (See
65 accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
66 copy at <a href=
67 "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
68 </div>
69</body>
70</html>