]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/Inserter.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / Inserter.rst
CommitLineData
7c673cae
FG
1.. Algorithms/Concepts//Inserter
2
3Inserter
4========
5
6Description
7-----------
8
9An |Inserter| is a compile-time substitute for STL |Output Iterator|.
10Under the hood, it's simply a type holding
11two entities: a *state* and an *operation*. When passed to a
12|transformation algorithm|, the inserter's binary operation is
13invoked for every element that would normally be written into the
14output iterator, with the element itself (as the second
15argument) and the result of the previous operation's invocation |--| or,
16for the very first element, the inserter's initial state.
17
18Technically, instead of taking a single inserter parameter,
19|transformation algorithms| could accept the state and the "output"
20operation separately. Grouping these in a single parameter entity,
21however, brings the algorithms semantically and syntactically closer to
22their STL counterparts, significantly simplifying many of the common
23use cases.
24
25
26Valid expressions
27-----------------
28
29|In the following table...| ``in`` is a model of |Inserter|.
30
31+-----------------------+-------------------------------+
32| Expression | Type |
33+=======================+===============================+
34| ``in::state`` | Any type |
35+-----------------------+-------------------------------+
36| ``in::operation`` | Binary |Lambda Expression| |
37+-----------------------+-------------------------------+
38
39
40Expression semantics
41--------------------
42
43+-----------------------+-------------------------------------------+
44| Expression | Semantics |
45+=======================+===========================================+
46| ``in::state`` | The inserter's initial state. |
47+-----------------------+-------------------------------------------+
48| ``in::operation`` | The inserter's "output" operation. |
49+-----------------------+-------------------------------------------+
50
51
52Example
53-------
54
55.. parsed-literal::
56
57 typedef transform<
58 range_c<int,0,10>
59 , plus<_1,_1>
60 , back_inserter< vector0<> >
61 >::type result;
62
63
64Models
65------
66
67* |[inserter]|
68* |front_inserter|
69* |back_inserter|
70
71See also
72--------
73
74|Algorithms|, |Transformation Algorithms|, |[inserter]|, |front_inserter|, |back_inserter|
75
76
77