~ubuntu-branches/debian/sid/boost1.49/sid

« back to all changes in this revision

Viewing changes to libs/mpl/doc/src/refmanual/vector.rst

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2012-02-26 00:31:44 UTC
  • Revision ID: package-import@ubuntu.com-20120226003144-eaytp12cbf6ubpms
Tags: upstream-1.49.0
Import upstream version 1.49.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. Sequences/Classes//vector |10
 
2
 
 
3
vector
 
4
======
 
5
 
 
6
Description
 
7
-----------
 
8
 
 
9
``vector`` is a |variadic|, `random access`__, `extensible`__ sequence of types that 
 
10
supports constant-time insertion and removal of elements at both ends, and 
 
11
linear-time insertion and removal of elements in the middle. On compilers that 
 
12
support the ``typeof`` extension, ``vector`` is the simplest and in many cases the
 
13
most efficient sequence.
 
14
 
 
15
__ `Random Access Sequence`_
 
16
__ `Extensible Sequence`_
 
17
 
 
18
Header
 
19
------
 
20
 
 
21
+-------------------+-------------------------------------------------------+
 
22
| Sequence form     | Header                                                |
 
23
+===================+=======================================================+
 
24
| Variadic          | ``#include <boost/mpl/vector.hpp>``                   |
 
25
+-------------------+-------------------------------------------------------+
 
26
| Numbered          | ``#include <boost/mpl/vector/vector``\ *n*\ ``.hpp>`` |
 
27
+-------------------+-------------------------------------------------------+
 
28
 
 
29
Model of
 
30
--------
 
31
 
 
32
* |Variadic Sequence|
 
33
* |Random Access Sequence|
 
34
* |Extensible Sequence|
 
35
* |Back Extensible Sequence|
 
36
* |Front Extensible Sequence|
 
37
 
 
38
 
 
39
Expression semantics
 
40
--------------------
 
41
 
 
42
In the following table, ``v`` is an instance of ``vector``, ``pos`` and ``last`` are iterators 
 
43
into ``v``, ``r`` is a |Forward Sequence|, ``n`` is an |Integral Constant|, and ``x`` and 
 
44
|t1...tn| are arbitrary types.
 
45
 
 
46
+---------------------------------------+-----------------------------------------------------------+
 
47
| Expression                            | Semantics                                                 |
 
48
+=======================================+===========================================================+
 
49
| .. parsed-literal::                   | ``vector`` of elements |t1...tn|; see                     |
 
50
|                                       | |Variadic Sequence|.                                      |
 
51
|    vector<|t1...tn|>                  |                                                           |
 
52
|    vector\ *n*\ <|t1...tn|>           |                                                           |
 
53
+---------------------------------------+-----------------------------------------------------------+
 
54
| .. parsed-literal::                   | Identical to ``vector``\ *n*\ ``<``\ |t1...tn|\ ``>``;    |
 
55
|                                       | see |Variadic Sequence|.                                  |
 
56
|    vector<|t1...tn|>::type            |                                                           |
 
57
|    vector\ *n*\ <|t1...tn|>::type     |                                                           |
 
58
+---------------------------------------+-----------------------------------------------------------+
 
59
| ``begin<v>::type``                    | An iterator pointing to the beginning of ``v``;           |
 
60
|                                       | see |Random Access Sequence|.                             |
 
61
+---------------------------------------+-----------------------------------------------------------+
 
62
| ``end<v>::type``                      | An iterator pointing to the end of ``v``;                 |
 
63
|                                       | see |Random Access Sequence|.                             |
 
64
+---------------------------------------+-----------------------------------------------------------+
 
65
| ``size<v>::type``                     | The size of ``v``; see |Random Access Sequence|.          |
 
66
+---------------------------------------+-----------------------------------------------------------+
 
67
| ``empty<v>::type``                    | |true if and only if| the sequence is empty;              |
 
68
|                                       | see |Random Access Sequence|.                             |
 
69
+---------------------------------------+-----------------------------------------------------------+
 
70
| ``front<v>::type``                    | The first element in ``v``; see                           |
 
71
|                                       | |Random Access Sequence|.                                 |
 
72
+---------------------------------------+-----------------------------------------------------------+
 
73
| ``back<v>::type``                     | The last element in ``v``; see                            |
 
74
|                                       | |Random Access Sequence|.                                 |
 
75
+---------------------------------------+-----------------------------------------------------------+
 
76
| ``at<v,n>::type``                     | The ``n``\ th element from the beginning of ``v``; see    |
 
77
|                                       | |Random Access Sequence|.                                 |
 
78
+---------------------------------------+-----------------------------------------------------------+
 
79
| ``insert<v,pos,x>::type``             | A new ``vector`` of following elements:                   |
 
80
|                                       | [``begin<v>::type``, ``pos``), ``x``,                     |
 
81
|                                       | [``pos``, ``end<v>::type``); see |Extensible Sequence|.   |
 
82
+---------------------------------------+-----------------------------------------------------------+
 
83
| ``insert_range<v,pos,r>::type``       | A new ``vector`` of following elements:                   |
 
84
|                                       | [``begin<v>::type``, ``pos``),                            |
 
85
|                                       | [``begin<r>::type``, ``end<r>::type``)                    |
 
86
|                                       | [``pos``, ``end<v>::type``); see |Extensible Sequence|.   |
 
87
+---------------------------------------+-----------------------------------------------------------+
 
88
| ``erase<v,pos>::type``                | A new ``vector`` of following elements:                   |
 
89
|                                       | [``begin<v>::type``, ``pos``),                            |
 
90
|                                       | [``next<pos>::type``, ``end<v>::type``); see              |
 
91
|                                       | |Extensible Sequence|.                                    |
 
92
+---------------------------------------+-----------------------------------------------------------+
 
93
| ``erase<v,pos,last>::type``           | A new ``vector`` of following elements:                   |
 
94
|                                       | [``begin<v>::type``, ``pos``),                            |
 
95
|                                       | [``last``, ``end<v>::type``); see |Extensible Sequence|.  |
 
96
+---------------------------------------+-----------------------------------------------------------+
 
97
| ``clear<v>::type``                    | An empty ``vector``; see |Extensible Sequence|.           |
 
98
+---------------------------------------+-----------------------------------------------------------+
 
99
| ``push_back<v,x>::type``              | A new ``vector`` of following elements:                   | 
 
100
|                                       | |begin/end<v>|, ``x``;                                    |
 
101
|                                       | see |Back Extensible Sequence|.                           |
 
102
+---------------------------------------+-----------------------------------------------------------+
 
103
| ``pop_back<v>::type``                 | A new ``vector`` of following elements:                   |
 
104
|                                       | [``begin<v>::type``, ``prior< end<v>::type >::type``);    |
 
105
|                                       | see |Back Extensible Sequence|.                           |
 
106
+---------------------------------------+-----------------------------------------------------------+
 
107
| ``push_front<v,x>::type``             | A new ``vector`` of following elements:                   |
 
108
|                                       | ``x``, |begin/end<v>|; see |Front Extensible Sequence|.   |
 
109
+---------------------------------------+-----------------------------------------------------------+
 
110
| ``pop_front<v>::type``                | A new ``vector`` of following elements:                   |
 
111
|                                       | [``next< begin<v>::type >::type``, ``end<v>::type``);     |
 
112
|                                       | see |Front Extensible Sequence|.                          |
 
113
+---------------------------------------+-----------------------------------------------------------+
 
114
 
 
115
 
 
116
Example
 
117
-------
 
118
 
 
119
.. parsed-literal::
 
120
    
 
121
    typedef vector<float,double,long double> floats;
 
122
    typedef push_back<floats,int>::type types;
 
123
 
 
124
    BOOST_MPL_ASSERT(( |is_same|\< at_c<types,3>::type, int > ));
 
125
 
 
126
 
 
127
See also
 
128
--------
 
129
 
 
130
|Sequences|, |Variadic Sequence|, |Random Access Sequence|, |Extensible Sequence|, |vector_c|, |list|
 
131
 
 
132
 
 
133
.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
 
134
   Distributed under the Boost Software License, Version 1.0. (See accompanying
 
135
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)