]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/preprocessor/doc/ref/mul_d.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / preprocessor / doc / ref / mul_d.html
CommitLineData
7c673cae
FG
1<html>
2<head>
3 <title>BOOST_PP_MUL_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_MUL_D</b> macro expands to the product of 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_MUL_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 multiplicand 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 multiplier 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 product of <i>x</i> and <i>y</i> is greater than <b>BOOST_PP_LIMIT_MAG</b>, the result is saturated to <b>BOOST_PP_LIMIT_MAG</b>.
35 </div>
36 <div>
37 This macro is the most efficient when <i>x</i> is greater than or equal to <i>y</i>.&nbsp;
38 However, the efficiency gain is not worth actually comparing the two arguments prior to invocation.&nbsp;
39 In other words, <i>x</i> should be the value that is <i>most likely</i> to be the largest of the two operands.
40 </div>
41 <h4>See Also</h4>
42 <ul>
43 <li><a href="limit_mag.html">BOOST_PP_LIMIT_MAG</a></li>
44 <li><a href="mul.html">BOOST_PP_MUL</a></li>
45 </ul>
46 <h4>Requirements</h4>
47 <div>
48 <b>Header:</b> &nbsp;<a href="../headers/arithmetic/mul.html">&lt;boost/preprocessor/arithmetic/mul.hpp&gt;</a>
49 </div>
50 <h4>Sample Code</h4>
51<div><pre>
52#include &lt;<a href="../headers/arithmetic/dec.html">boost/preprocessor/arithmetic/dec.hpp</a>&gt;
53#include &lt;<a href="../headers/arithmetic/mul.html">boost/preprocessor/arithmetic/mul.hpp</a>&gt;
54#include &lt;<a href="../headers/control/while.html">boost/preprocessor/control/while.hpp</a>&gt;
55#include &lt;<a href="../headers/tuple/elem.html">boost/preprocessor/tuple/elem.hpp</a>&gt;
56
57#define PRED(d, data) <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(3, 0, data)
58
59#define OP(d, data) \
60 ( \
61 <a href="dec.html">BOOST_PP_DEC</a>( \
62 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(3, 0, data) \
63 ), \
64 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(3, 1, data), \
65 <a href="mul_d.html">BOOST_PP_MUL_D</a>( \
66 d, \
67 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(3, 2, data), \
68 <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(3, 1, data) \
69 ) \
70 ) \
71 /**/
72
73// raise 'x' to the 'n'-th power
74#define EXP(x, n) <a href="tuple_elem.html">BOOST_PP_TUPLE_ELEM</a>(3, 2, <a href="while.html">BOOST_PP_WHILE</a>(PRED, OP, (n, x, 1)))
75
76EXP(4, 2) // expands to 16
77EXP(2, 3) // expands to 8
78</pre></div>
79 <hr size="1">
80 <div style="margin-left: 0px;">
81