]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/vmd/doc/vmd_sequence_access.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / vmd / doc / vmd_sequence_access.qbk
1 [/
2 (C) Copyright Edward Diener 2011-2015
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6 ]
7
8 [section:vmd_sequence_access Accessing a sequence element]
9
10 It is possible to access an individual element of a sequence.
11 The macro to do this is called BOOST_VMD_ELEM. The macro takes two
12 required parameters. The required parameters are the element number
13 to access and the sequence, in that order. The element number is a
14 0-based number and its maximum value should be one less than the size
15 of the sequence.
16
17 The BOOST_VMD_ELEM macro returns the actual sequence element. If the
18 first required parameter is greater or equal to the size of the
19 sequence the macro returns emptiness. Because of this using
20 BOOST_VMD_ELEM on an empty sequence, whose size is 0, always returns
21 emptiness.
22
23 #include <boost/vmd/elem.hpp>
24
25 #define BOOST_VMD_REGISTER_ANAME (ANAME)
26 #define A_SEQUENCE (1,2,3) 46 (list_data1,(list_data2,BOOST_PP_NIL)) BOOST_VMD_TYPE_SEQ ANAME
27 #define AN_EMPTY_SEQUENCE
28
29 BOOST_VMD_ELEM(0,A_SEQUENCE) will return (1,2,3)
30 BOOST_VMD_ELEM(1,A_SEQUENCE) will return 46
31 BOOST_VMD_ELEM(2,A_SEQUENCE) will return (list_data1,(list_data2,BOOST_PP_NIL))
32 BOOST_VMD_ELEM(3,A_SEQUENCE) will return BOOST_VMD_TYPE_SEQ
33 BOOST_VMD_ELEM(4,A_SEQUENCE) will return ANAME
34
35 BOOST_VMD_ELEM(5,A_SEQUENCE) will return emptiness
36 BOOST_VMD_ELEM(0,AN_EMPTY_SEQUENCE) will return emptiness
37
38 Accessing an element of a sequence directly is slower than accessing an element
39 of a Boost PP data type or even variadic data, since each access has to directly
40 cycle through each element of the sequence to get to the one being accessed.
41 The process of sequentially parsing each element again each time is slower than
42 accessing a Boost PP data type element.
43
44 [heading Usage]
45
46 You can use the general header file:
47
48 #include <boost/vmd/vmd.hpp>
49
50 or you can use the individual header file:
51
52 #include <boost/vmd/elem.hpp>
53
54 [endsect]