• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1++++++++++++++++++++++++++++++++++
2 |Boost| Pointer Container Library
3++++++++++++++++++++++++++++++++++
4
5.. |Boost| image:: boost.png
6
7Insert Iterators
8----------------
9
10When you work with normal value-based containers and algorithms, you often
11use insert iterators ::
12
13       std::list<int> coll1;
14       // ...
15       std::vector<int> coll2;
16       std::copy( coll1.begin(), coll1.end(),
17                  back_inserter(coll2) );
18
19With the special insert iterators for pointer containers,
20you can do exactly the same ::
21
22       boost::ptr_list<Base> coll1;
23       // ...
24       boost::ptr_vector<Base> coll2;
25       std::copy( coll1.begin(), coll1.end(),
26                  boost::ptr_container::ptr_back_inserter(coll2) );
27
28Each element is cloned and inserted into the container. Furthermore,
29if the source range iterates over pointers
30instead of references, ``NULL`` pointers
31can be transfered as well.
32
33**Navigate**
34
35- `home <ptr_container.html>`_
36- `reference <reference.html>`_
37
38**Synopsis:**
39
40::
41
42        namespace boost
43        {
44            namespace ptr_container
45            {
46
47                template< class PtrContainer >
48                class ptr_back_insert_iterator;
49
50                template< class PtrContainer >
51                class ptr_front_insert_iterator;
52
53                template< class PtrContainer >
54                class ptr_insert_iterator;
55
56                template< class PtrContainer >
57                ptr_back_insert_iterator<PtrContainer>
58                ptr_back_inserter( PtrContainer& cont );
59
60                template< class PtrContainer >
61                ptr_front_insert_iterator<PtrContainer>
62                ptr_front_inserter( PtrContainer& cont );
63
64                template< class PtrContainer >
65                ptr_insert_iterator<PtrContainer>
66                ptr_inserter( PtrContainer& cont, typename PtrContainer::iterator before );
67
68            } // namespace 'ptr_container'
69        } // namespace 'boost'
70
71.. raw:: html
72
73        <hr>
74
75:Copyright:     Thorsten Ottosen 2008. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
76
77__ http://www.boost.org/LICENSE_1_0.txt
78
79
80