]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <title>BOOST_PP_SEQ_FOLD_LEFT_s</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_<i>s</i></b> macro folds (or accumulates) the | |
9 | elements of a <i>seq</i> left-to-right. It reenters <b>BOOST_PP_SEQ_FOLD_LEFT</b> | |
10 | with maximum efficiency. | |
11 | </div> | |
12 | <h4> | |
13 | Usage | |
14 | </h4> | |
15 | <div class="code"> | |
16 | <b>BOOST_PP_SEQ_FOLD_LEFT_</b> ## <i>s</i>(<i>op</i>, <i>state</i>, <i>seq</i>) | |
17 | </div> | |
18 | <h4> | |
19 | Arguments | |
20 | </h4> | |
21 | <dl> | |
22 | <dt>s</dt> | |
23 | <dd> | |
24 | The next available <b>BOOST_PP_SEQ_FOLD_LEFT</b> fold step. | |
25 | </dd> | |
26 | <dt>op</dt> | |
27 | <dd> | |
28 | A ternary operation of the form <i>op</i>(<i>s</i>, <i>state</i>, <i>elem</i>). | |
29 | This macro is called for each element in <i>seq</i>--each time returning a new <i>state</i>. | |
30 | This operation is expanded by <b>BOOST_PP_SEQ_FOLD_LEFT</b> with the next | |
31 | available fold step, the current <i>state</i>, and the current element. | |
32 | </dd> | |
33 | <dt>state</dt> | |
34 | <dd> | |
35 | The initial state of the fold. | |
36 | </dd> | |
37 | <dt>seq</dt> | |
38 | <dd> | |
39 | The <i>seq</i> to be folded. | |
40 | </dd> | |
41 | </dl> | |
42 | <h4> | |
43 | Remarks | |
44 | </h4> | |
45 | <div> | |
46 | For the <i>seq</i>, (<i>0</i>)(<i>1</i>)(<i>2</i>), this macro expands to: | |
47 | <div> | |
48 | <i>op</i>(<i>s</i>, <i>op</i>(<i>s</i>, <i>op</i>(<i>s</i>, <i>state</i>, <i>0</i>), | |
49 | <i>1</i>), <i>2</i>) | |
50 | </div> | |
51 | </div> | |
52 | <h4> | |
53 | See Also | |
54 | </h4> | |
55 | <ul> | |
56 | <li> | |
57 | <a href="seq_fold_left.html">BOOST_PP_SEQ_FOLD_LEFT</a></li> | |
58 | </ul> | |
59 | <h4> | |
60 | Requirements | |
61 | </h4> | |
62 | <div> | |
63 | <b>Header:</b> <a href="../headers/seq/fold_left.html"><boost/preprocessor/seq/fold_left.hpp></a> | |
64 | </div> | |
65 | <h4> | |
66 | Sample Code | |
67 | </h4> | |
68 | <div> | |
69 | <pre> | |
70 | #include <<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>> | |
71 | #include <<a href="../headers/seq/fold_left.html">boost/preprocessor/seq/fold_left.hpp</a>> | |
72 | #include <<a href="../headers/seq/seq.html">boost/preprocessor/seq/seq.hpp</a>> | |
73 | ||
74 | #define S1 (a)(b)(c) | |
75 | #define S2 (S1)(S1)(S1) | |
76 | ||
77 | #define OP(s, state, x) state (<a href="seq_fold_left_s.html">BOOST_PP_SEQ_FOLD_LEFT_</a> ## s(OP_2, _, x)) | |
78 | #define OP_2(s, state, x) <a href="cat.html">BOOST_PP_CAT</a>(state, x) | |
79 | ||
80 | <a href="seq_fold_left.html">BOOST_PP_SEQ_FOLD_LEFT</a>(OP, <a href="seq_nil.html">BOOST_PP_SEQ_NIL</a>, S2) | |
81 | // expands to (_abc)(_abc)(_abc) | |
82 | </pre> | |
83 | </div> | |
84 | <hr size="1"> | |
85 | <div style="margin-left: 0px;"> | |
86 |