• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Algorithms/Transformation Algorithms//copy |10
2
3copy
4====
5
6Synopsis
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
22Description
23-----------
24
25Returns a copy of the original sequence.
26
27|transformation algorithm disclaimer|
28
29
30Header
31------
32
33.. parsed-literal::
34
35    #include <boost/mpl/copy.hpp>
36
37
38Model of
39--------
40
41|Reversible Algorithm|
42
43
44Parameters
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
56Expression semantics
57--------------------
58
59|Semantics disclaimer...| |Reversible Algorithm|.
60
61For 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
79Complexity
80----------
81
82Linear. Exactly ``size<s>::value`` applications of ``in::operation``.
83
84
85Example
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
100See also
101--------
102
103|Transformation Algorithms|, |Reversible Algorithm|, |reverse_copy|, |copy_if|, |transform|
104
105
106.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
107   Distributed under the Boost Software License, Version 1.0. (See accompanying
108   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
109