blob: 1142c9027bb3f32513763e67a0c0801451fa064c [file] [log] [blame]
Brian Silvermanf27e0852018-08-04 23:56:45 -07001<html>
2<head>
3 <title>BOOST_PP_SUB_D</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_SUB_D</b> macro expands to the difference between its second and third arguments.&nbsp;
9 It reenters <b>BOOST_PP_WHILE</b> with maximum efficiency.
10 </div>
11 <h4>Usage</h4>
12 <div class="code">
13 <b>BOOST_PP_SUB_D</b>(<i>d</i>, <i>x</i>, <i>y</i>)
14 </div>
15 <h4>Arguments</h4>
16 <dl>
17 <dt>d</dt>
18 <dd>
19 The next available <b>BOOST_PP_WHILE</b> iteration.&nbsp;
20 </dd>
21 <dt>x</dt>
22 <dd>
23 The minuend of the operation.&nbsp;
24 Valid values range from <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.
25 </dd>
26 <dt>y</dt>
27 <dd>
28 The subtrahend of the operation.&nbsp;
29 Valid values range from <i>0</i> to <b>BOOST_PP_LIMIT_MAG</b>.
30 </dd>
31 </dl>
32 <h4>Remarks</h4>
33 <div>
34 If the difference between <i>x</i> and <i>y</i> is less than <i>0</i>, the result is saturated to <i>0</i>.
35 </div>
36 <h4>See Also</h4>
37 <ul>
38 <li><a href="limit_mag.html">BOOST_PP_LIMIT_MAG</a></li>
39 <li><a href="sub.html">BOOST_PP_SUB</a></li>
40 </ul>
41 <h4>Requirements</h4>
42 <div>
43 <b>Header:</b> &nbsp;<a href="../headers/arithmetic/sub.html">&lt;boost/preprocessor/arithmetic/sub.hpp&gt;</a>
44 </div>
45 <h4>Sample Code</h4>
46<div><pre>
47#include &lt;<a href="../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp</a>&gt;
48#include &lt;<a href="../headers/arithmetic/sub.html">boost/preprocessor/arithmetic/sub.hpp</a>&gt;
49#include &lt;<a href="../headers/control/while.html">boost/preprocessor/control/while.hpp</a>&gt;
50#include &lt;<a href="../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp</a>&gt;
51
52#define PRED(d, data) <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(2, 0, data)
53
54#define OP(d, data) \
55 ( \
56 <a href="dec.html">BOOST_PP_DEC</a>( \
57 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(2, 0, data) \
58 ), \
59 <a href="sub_d.html">BOOST_PP_SUB_D</a>( \
60 d, \
61 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(2, 1, data), \
62 2 \
63 ) \
64 ) \
65 /**/
66
67// decrement 'x' by 2 'n' times
68#define STRIDE(x, n) <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(2, 1, <a href="while.html">BOOST_PP_WHILE</a>(PRED, OP, (n, x)))
69
70STRIDE(10, 2) // expands to 6
71STRIDE(14, 6) // expands to 2
72</pre></div>
73 <hr size="1">
74 <div style="margin-left: 0px;">
75 <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
76 </br><i>© Copyright Paul Mensonides 2002</i>
77 </div>
78 <div style="margin-left: 0px;">
79 <p><small>Distributed under the Boost Software License, Version 1.0. (See
80 accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
81 copy at <a href=
82 "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
83 </div>
84</body>
85</html>