Chris@16
|
1 //
|
Chris@16
|
2 // Boost.Pointer Container
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
|
Chris@16
|
5 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // For more information, see http://www.boost.org/libs/ptr_container/
|
Chris@16
|
10 //
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_PTR_CONTAINER_PTR_VECTOR_HPP
|
Chris@16
|
13 #define BOOST_PTR_CONTAINER_PTR_VECTOR_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
16 # pragma once
|
Chris@16
|
17 #endif
|
Chris@16
|
18
|
Chris@16
|
19 #include <vector>
|
Chris@16
|
20 #include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 namespace boost
|
Chris@16
|
23 {
|
Chris@16
|
24
|
Chris@16
|
25 template
|
Chris@16
|
26 <
|
Chris@16
|
27 class T,
|
Chris@16
|
28 class CloneAllocator = heap_clone_allocator,
|
Chris@16
|
29 class Allocator = std::allocator<void*>
|
Chris@16
|
30 >
|
Chris@16
|
31 class ptr_vector : public
|
Chris@16
|
32 ptr_sequence_adapter< T,
|
Chris@16
|
33 std::vector<void*,Allocator>,
|
Chris@16
|
34 CloneAllocator >
|
Chris@16
|
35 {
|
Chris@16
|
36 typedef ptr_sequence_adapter< T,
|
Chris@16
|
37 std::vector<void*,Allocator>,
|
Chris@16
|
38 CloneAllocator >
|
Chris@16
|
39 base_class;
|
Chris@16
|
40
|
Chris@16
|
41 typedef ptr_vector<T,CloneAllocator,Allocator> this_type;
|
Chris@16
|
42
|
Chris@16
|
43 public:
|
Chris@16
|
44
|
Chris@16
|
45 BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_vector,
|
Chris@16
|
46 base_class,
|
Chris@16
|
47 this_type )
|
Chris@16
|
48
|
Chris@16
|
49 explicit ptr_vector( size_type n,
|
Chris@16
|
50 const allocator_type& alloc = allocator_type() )
|
Chris@16
|
51 : base_class(alloc)
|
Chris@16
|
52 {
|
Chris@16
|
53 this->base().reserve( n );
|
Chris@16
|
54 }
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
58 // clonability
|
Chris@16
|
59
|
Chris@16
|
60 template< typename T, typename CA, typename A >
|
Chris@16
|
61 inline ptr_vector<T,CA,A>* new_clone( const ptr_vector<T,CA,A>& r )
|
Chris@16
|
62 {
|
Chris@16
|
63 return r.clone().release();
|
Chris@16
|
64 }
|
Chris@16
|
65
|
Chris@16
|
66 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
67 // swap
|
Chris@16
|
68
|
Chris@16
|
69 template< typename T, typename CA, typename A >
|
Chris@16
|
70 inline void swap( ptr_vector<T,CA,A>& l, ptr_vector<T,CA,A>& r )
|
Chris@16
|
71 {
|
Chris@16
|
72 l.swap(r);
|
Chris@16
|
73 }
|
Chris@16
|
74
|
Chris@16
|
75 }
|
Chris@16
|
76
|
Chris@16
|
77 #endif
|