]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Algorithms/Transformation Algorithms//copy |10 |
2 | ||
3 | copy | |
4 | ==== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | , typename In = |unspecified| | |
14 | > | |
15 | struct copy | |
16 | { | |
17 | typedef |unspecified| type; | |
18 | }; | |
19 | ||
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Returns a copy of the original sequence. | |
26 | ||
27 | |transformation algorithm disclaimer| | |
28 | ||
29 | ||
30 | Header | |
31 | ------ | |
32 | ||
33 | .. parsed-literal:: | |
34 | ||
35 | #include <boost/mpl/copy.hpp> | |
36 | ||
37 | ||
38 | Model of | |
39 | -------- | |
40 | ||
41 | |Reversible Algorithm| | |
42 | ||
43 | ||
44 | Parameters | |
45 | ---------- | |
46 | ||
47 | +---------------+---------------------------+-------------------------------+ | |
48 | | Parameter | Requirement | Description | | |
49 | +===============+===========================+===============================+ | |
50 | | ``Sequence`` | |Forward Sequence| | A sequence to copy. | | |
51 | +---------------+---------------------------+-------------------------------+ | |
52 | | ``In`` | |Inserter| | An inserter. | | |
53 | +---------------+---------------------------+-------------------------------+ | |
54 | ||
55 | ||
56 | Expression semantics | |
57 | -------------------- | |
58 | ||
59 | |Semantics disclaimer...| |Reversible Algorithm|. | |
60 | ||
61 | For any |Forward Sequence| ``s``, and an |Inserter| ``in``: | |
62 | ||
63 | .. parsed-literal:: | |
64 | ||
65 | typedef copy<s,in>::type r; | |
66 | ||
67 | :Return type: | |
68 | A type. | |
69 | ||
70 | :Semantics: | |
71 | Equivalent to | |
72 | ||
73 | .. parsed-literal:: | |
74 | ||
75 | typedef fold< s,in::state,in::operation >::type r; | |
76 | ||
77 | ||
78 | ||
79 | Complexity | |
80 | ---------- | |
81 | ||
82 | Linear. Exactly ``size<s>::value`` applications of ``in::operation``. | |
83 | ||
84 | ||
85 | Example | |
86 | ------- | |
87 | ||
88 | .. parsed-literal:: | |
89 | ||
90 | typedef vector_c<int,0,1,2,3,4,5,6,7,8,9> numbers; | |
91 | typedef copy< | |
92 | range_c<int,10,20> | |
93 | , back_inserter< numbers > | |
94 | >::type result; | |
95 | ||
96 | BOOST_MPL_ASSERT_RELATION( size<result>::value, ==, 20 ); | |
97 | BOOST_MPL_ASSERT(( equal< result,range_c<int,0,20> > )); | |
98 | ||
99 | ||
100 | See also | |
101 | -------- | |
102 | ||
103 | |Transformation Algorithms|, |Reversible Algorithm|, |reverse_copy|, |copy_if|, |transform| | |
104 | ||
105 | ||
106 |