Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/preprocessor/doc/data/sequences.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.4 KB
Line 
1<html>
2        <head>
3                <title>sequences.html</title>
4                <link rel="stylesheet" type="text/css" href="../styles.css">
5        </head>
6        <body>
7                <h4>
8                        Sequences
9                </h4>
10                <div>
11                        A <i>sequence</i> (abbreviated to <i>seq</i>) is a group of adjacent parenthesized elements. For example,
12                </div>
13                <div class="code">
14                        (<i>a</i>)(<i>b</i>)(<i>c</i>)
15                </div>
16                <div>
17                        ...is a <i>seq</i> of <i>3</i> elements--<i>a</i>, <i>b</i>, and <i>c</i>.
18                </div>
19                <div>
20                        <i>Sequences</i> are data structures that merge the properties of both <i>lists</i> and
21                        <i>tuples</i> with the exception that a <i>seq</i> cannot be empty.&nbsp; 
22                        Therefore, an "empty" <i>seq</i> is considered a special case scenario that
23                        must be handled separately in C++.
24                </div>
25                <div class="code">
26                        <pre>
27#define SEQ (x)(y)(z)
28#define REVERSE(s, state, elem) (elem) state
29   // append to head                  ^
30
31BOOST_PP_SEQ_FOLD_LEFT(REVERSE, BOOST_PP_EMPTY, SEQ)()
32   //                           #1                  #2
33   // 1) placeholder for "empty" seq
34   // 2) remove placeholder
35
36#define SEQ_B (1)(2)(3)
37#define INC(s, state, elem) state (BOOST_PP_INC(elem))
38   // append to tail             ^
39
40BOOST_PP_SEQ_FOLD_RIGHT(INC, BOOST_PP_SEQ_NIL, SEQ)
41   //                        ^
42   // special placeholder that will be "eaten"
43   // by appending to the tail
44</pre>
45                </div>
46                <div>
47                        <i>Sequences</i> are extremely efficient.&nbsp; Element access speed approaches
48                        random access--even with <i>seqs</i> of up to <i>256</i> elements.&nbsp; This
49                        is because element access (among other things) is implemented iteratively
50                        rather than recursively.&nbsp; Therefore, elements can be accessed at extremely
51                        high indices even on preprocessors with low maximum expansion depths.
52                </div>
53                <div>
54                        Elements of a <i>seq</i> can be extracted with <b>BOOST_PP_SEQ_ELEM</b>.
55                </div>
56                <h4>
57                        Primitives
58                </h4>
59                <ul>
60                        <li>
61                                <a href="../ref/seq_elem.html">BOOST_PP_SEQ_ELEM</a></li>
62                </ul>
63        <hr size="1">
64        <div style="margin-left: 0px;">
65                <i>© Copyright <a href="http://www.housemarque.com" target="_top">Housemarque Oy</a> 2002</i>
66                </br><i>© Copyright Paul Mensonides 2002</i>
67        </div>
68        <div style="margin-left: 0px;">
69                <p><small>Distributed under the Boost Software License, Version 1.0. (See
70                accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
71                copy at <a href=
72                "http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
73        </div>
74        </body>
75</html>
Note: See TracBrowser for help on using the repository browser.