Brian Silverman | f27e085 | 2018-08-04 23:56:45 -0700 | [diff] [blame^] | 1 | <html> |
| 2 | <head> |
| 3 | <title>BOOST_PP_SEQ_FOLD_LEFT</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_SEQ_FOLD_LEFT</b> macro folds (or accumulates) the elements of |
| 9 | a <i>seq</i> left-to-right. |
| 10 | </div> |
| 11 | <h4> |
| 12 | Usage |
| 13 | </h4> |
| 14 | <div class="code"> |
| 15 | <b>BOOST_PP_SEQ_FOLD_LEFT</b>(<i>op</i>, <i>state</i>, <i>seq</i>) |
| 16 | </div> |
| 17 | <h4> |
| 18 | Arguments |
| 19 | </h4> |
| 20 | <dl> |
| 21 | <dt>op</dt> |
| 22 | <dd> |
| 23 | A ternary operation of the form <i>op</i>(<i>s</i>, <i>state</i>, <i>elem</i>). |
| 24 | This macro is called for each element in <i>seq</i>--each time returning a new <i>state</i>. |
| 25 | This operation is expanded by <b>BOOST_PP_SEQ_FOLD_LEFT</b> with the next |
| 26 | available fold step, the current <i>state</i>, and the current element. |
| 27 | </dd> |
| 28 | <dt>state</dt> |
| 29 | <dd> |
| 30 | The initial state of the fold. |
| 31 | </dd> |
| 32 | <dt>seq</dt> |
| 33 | <dd> |
| 34 | The <i>seq</i> to be folded. |
| 35 | </dd> |
| 36 | </dl> |
| 37 | <h4> |
| 38 | Remarks |
| 39 | </h4> |
| 40 | <div> |
| 41 | For the <i>seq</i>, (<i>0</i>)(<i>1</i>)(<i>2</i>), this macro expands to: |
| 42 | <div> |
| 43 | <i>op</i>(<i>s</i>, <i>op</i>(<i>s</i>, <i>op</i>(<i>s</i>, <i>state</i>, <i>0</i>), |
| 44 | <i>1</i>), <i>2</i>) |
| 45 | </div> |
| 46 | </div> |
| 47 | <div> |
| 48 | For maximum efficiency, <b>BOOST_PP_SEQ_FOLD_LEFT</b> can be reentered with <b>BOOST_PP_SEQ_FOLD_LEFT_<i>s</i></b>. |
| 49 | </div> |
| 50 | <h4> |
| 51 | See Also |
| 52 | </h4> |
| 53 | <ul> |
| 54 | <li> |
| 55 | <a href="seq_fold_left_s.html">BOOST_PP_SEQ_FOLD_LEFT_<i>s</i></a></li> |
| 56 | </ul> |
| 57 | <h4> |
| 58 | Requirements |
| 59 | </h4> |
| 60 | <div> |
| 61 | <b>Header:</b> <a href="../headers/seq/fold_left.html"><boost/preprocessor/seq/fold_left.hpp></a> |
| 62 | </div> |
| 63 | <h4> |
| 64 | Sample Code |
| 65 | </h4> |
| 66 | <div> |
| 67 | <pre> |
| 68 | #include <<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>> |
| 69 | #include <<a href="../headers/seq/fold_left.html">boost/preprocessor/seq/fold_left.hpp</a>> |
| 70 | |
| 71 | #define SEQ (b)(o)(o)(s)(t) |
| 72 | |
| 73 | #define OP(s, state, x) <a href="cat.html">BOOST_PP_CAT</a>(state, x) |
| 74 | |
| 75 | <a href="seq_fold_left.html">BOOST_PP_SEQ_FOLD_LEFT</a>(OP, <a href="seq_head.html">BOOST_PP_SEQ_HEAD</a>(SEQ), <a href="seq_tail.html">BOOST_PP_SEQ_TAIL</a>(SEQ)) // expands to boost |
| 76 | </pre> |
| 77 | </div> |
| 78 | <hr size="1"> |
| 79 | <div style="margin-left: 0px;"> |
| 80 | <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i> |
| 81 | </br><i>© Copyright Paul Mensonides 2002</i> |
| 82 | </div> |
| 83 | <div style="margin-left: 0px;"> |
| 84 | <p><small>Distributed under the Boost Software License, Version 1.0. (See |
| 85 | accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or |
| 86 | copy at <a href= |
| 87 | "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p> |
| 88 | </div> |
| 89 | </body> |
| 90 | </html> |