• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Sequences/Concepts//Variadic Sequence |100
2
3Variadic Sequence
4=================
5
6Description
7-----------
8
9A |Variadic Sequence| is a member of a family of sequence classes with both
10*variadic* and *numbered* forms. If ``seq`` is a generic name for some
11|Variadic Sequence|, its *variadic form* allows us to specify a sequence of
12*n* elements |t1...tn|, for any *n* from 0 up to a
13`preprocessor-configurable limit`__ ``BOOST_MPL_LIMIT_``\ *seq*\ ``_SIZE``,
14using the following notation:
15
16__ `Configuration`_
17
18    .. line-block::
19
20        ``seq<``\ |t1...tn|\ ``>``
21
22By contrast, each *numbered* sequence form accepts the exact number of elements
23that is encoded in the name of the corresponding class template:
24
25    .. line-block::
26
27        ``seq``\ *n*\ ``<``\ |t1...tn|\ ``>``
28
29For numbered forms, there is no predefined top limit for *n*, aside from compiler
30limitations on the number of template parameters.
31
32.. The variadic form of sequence ``seq`` is defined in
33   ``<boost/mpl/``\ *seq*\ ``.hpp>`` header.
34   The numbered forms are defined in batches of 10.
35
36
37Expression requirements
38-----------------------
39
40|In the following table...| ``seq`` is a placeholder token for the actual
41|Variadic Sequence| name.
42
43.. |seq<t1...tn>| replace:: ``seq<``\ |t1...tn|\ ``>``
44.. |seq<t1...tn>::type| replace:: ``seq<``\ |t1...tn|\ ``>::type``
45
46.. |seqn<t1...tn>| replace:: ``seq``\ *n*\ ``<``\ |t1...tn|\ ``>``
47.. |seqn<t1...tn>::type| replace:: ``seq``\ *n*\ ``<``\ |t1...tn|\ ``>::type``
48
49
50+---------------------------+-----------------------+---------------------------+
51| Expression                | Type                  | Complexity                |
52+===========================+=======================+===========================+
53| |seq<t1...tn>|            | |Forward Sequence|    | Amortized constant time   |
54+---------------------------+-----------------------+---------------------------+
55| |seq<t1...tn>::type|      | |Forward Sequence|    | Amortized constant time   |
56+---------------------------+-----------------------+---------------------------+
57| |seqn<t1...tn>|           | |Forward Sequence|    | Amortized constant time   |
58+---------------------------+-----------------------+---------------------------+
59| |seqn<t1...tn>::type|     | |Forward Sequence|    | Amortized constant time   |
60+---------------------------+-----------------------+---------------------------+
61
62
63Expression semantics
64--------------------
65
66
67.. parsed-literal::
68
69    typedef seq<|t1...tn|> s;
70    typedef seq\ *n*\ <|t1...tn|> s;
71
72:Semantics:
73    ``s`` is a sequence of elements |t1...tn|.
74
75:Postcondition:
76    ``size<s>::value == n``.
77
78    .. FIXME .. parsed-literal::
79
80        BOOST_MPL_ASSERT((|is_same|\< at_c<v,0>::type,\ |t1| >));
81        BOOST_MPL_ASSERT((|is_same|\< at_c<v,1>::type,\ |t2| >));
82        ...
83        BOOST_MPL_ASSERT((|is_same|\< at_c<v,\ *n*>::type,\ |tn| >));
84
85.. ..........................................................................
86
87.. parsed-literal::
88
89    typedef seq<|t1...tn|>::type s;
90    typedef seq\ *n*\ <|t1...tn|>::type s;
91
92:Semantics:
93    ``s`` is identical to ``seq``\ *n*\ ``<``\ |t1...tn| ``>``.
94
95:Postcondition:
96    ``size<s>::value == n``.
97
98
99Models
100------
101
102* |vector|
103* |list|
104* |map|
105
106See also
107--------
108
109|Sequences|, |Configuration|, |Integral Sequence Wrapper|
110
111.. |variadic| replace:: `variadic`_
112.. _`variadic`: `Variadic Sequence`_
113
114.. |variadic forms| replace:: `variadic forms`_
115.. _`variadic forms`: `Variadic Sequence`_
116
117.. |numbered forms| replace:: `numbered forms`_
118.. _`numbered forms`: `Variadic Sequence`_
119
120
121.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
122   Distributed under the Boost Software License, Version 1.0. (See accompanying
123   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
124