]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // |
2 | // Boost.Pointer Container | |
3 | // | |
4 | // Copyright Thorsten Ottosen 2003-2005. Use, modification and | |
5 | // distribution is subject to the Boost Software License, Version | |
6 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | // | |
9 | // For more information, see http://www.boost.org/libs/ptr_container/ | |
10 | // | |
11 | ||
12 | #ifndef BOOST_PTR_CONTAINER_PTR_VECTOR_HPP | |
13 | #define BOOST_PTR_CONTAINER_PTR_VECTOR_HPP | |
14 | ||
15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
16 | # pragma once | |
17 | #endif | |
18 | ||
19 | #include <vector> | |
20 | #include <boost/ptr_container/ptr_sequence_adapter.hpp> | |
11fdf7f2 | 21 | #include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp> |
92f5a8d4 TL |
22 | #include <boost/type_traits/is_same.hpp> |
23 | #include <boost/mpl/if.hpp> | |
11fdf7f2 TL |
24 | |
25 | #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED) | |
26 | #pragma GCC diagnostic push | |
27 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
28 | #endif | |
7c673cae FG |
29 | |
30 | namespace boost | |
31 | { | |
32 | ||
33 | template | |
34 | < | |
35 | class T, | |
36 | class CloneAllocator = heap_clone_allocator, | |
92f5a8d4 | 37 | class Allocator = void |
7c673cae FG |
38 | > |
39 | class ptr_vector : public | |
92f5a8d4 TL |
40 | ptr_sequence_adapter< T, |
41 | std::vector< | |
42 | typename ptr_container_detail::void_ptr<T>::type, | |
43 | typename boost::mpl::if_<boost::is_same<Allocator, void>, | |
44 | std::allocator<typename ptr_container_detail::void_ptr<T>::type>, Allocator>::type | |
45 | >, | |
46 | CloneAllocator > | |
7c673cae | 47 | { |
92f5a8d4 TL |
48 | typedef |
49 | ||
50 | ptr_sequence_adapter< T, | |
51 | std::vector< | |
52 | typename ptr_container_detail::void_ptr<T>::type, | |
53 | typename boost::mpl::if_<boost::is_same<Allocator, void>, | |
54 | std::allocator<typename ptr_container_detail::void_ptr<T>::type>, Allocator>::type | |
55 | >, | |
56 | CloneAllocator > | |
57 | ||
7c673cae FG |
58 | base_class; |
59 | ||
60 | typedef ptr_vector<T,CloneAllocator,Allocator> this_type; | |
61 | ||
62 | public: | |
63 | ||
64 | BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_vector, | |
65 | base_class, | |
66 | this_type ) | |
67 | ||
68 | explicit ptr_vector( size_type n, | |
69 | const allocator_type& alloc = allocator_type() ) | |
70 | : base_class(alloc) | |
71 | { | |
72 | this->base().reserve( n ); | |
73 | } | |
74 | }; | |
75 | ||
76 | ////////////////////////////////////////////////////////////////////////////// | |
77 | // clonability | |
78 | ||
79 | template< typename T, typename CA, typename A > | |
80 | inline ptr_vector<T,CA,A>* new_clone( const ptr_vector<T,CA,A>& r ) | |
81 | { | |
82 | return r.clone().release(); | |
83 | } | |
84 | ||
85 | ///////////////////////////////////////////////////////////////////////// | |
86 | // swap | |
87 | ||
88 | template< typename T, typename CA, typename A > | |
89 | inline void swap( ptr_vector<T,CA,A>& l, ptr_vector<T,CA,A>& r ) | |
90 | { | |
91 | l.swap(r); | |
92 | } | |
93 | ||
94 | } | |
95 | ||
11fdf7f2 TL |
96 | #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED) |
97 | #pragma GCC diagnostic pop | |
98 | #endif | |
99 | ||
7c673cae | 100 | #endif |