]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/ptr_container/ptr_map.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / ptr_container / ptr_map.hpp
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_MAP_HPP
13 #define BOOST_PTR_CONTAINER_PTR_MAP_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif
18
19 #include <map>
20 #include <boost/ptr_container/ptr_map_adapter.hpp>
21
22 namespace boost
23 {
24
25 template
26 <
27 class Key,
28 class T,
29 class Compare = std::less<Key>,
30 class CloneAllocator = heap_clone_allocator,
31 class Allocator = std::allocator< std::pair<const Key,typename ptr_container_detail::void_ptr<T>::type> >
32 >
33 class ptr_map :
34 public ptr_map_adapter<T,std::map<Key,
35 typename ptr_container_detail::void_ptr<T>::type,
36 Compare,Allocator>,CloneAllocator>
37 {
38 typedef ptr_map_adapter<T,std::map<Key,
39 typename ptr_container_detail::void_ptr<T>::type,
40 Compare,Allocator>,CloneAllocator>
41 base_type;
42
43 typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
44
45 public:
46 ptr_map()
47 { }
48
49 explicit ptr_map( const Compare& comp,
50 const Allocator& a = Allocator() )
51 : base_type( comp, a ) { }
52
53 template< class InputIterator >
54 ptr_map( InputIterator first, InputIterator last )
55 : base_type( first, last )
56 { }
57
58 template< class InputIterator >
59 ptr_map( InputIterator first, InputIterator last,
60 const Compare& comp,
61 const Allocator& a = Allocator() )
62 : base_type( first, last, comp, a )
63 { }
64
65 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map, base_type,
66 this_type )
67
68 template< class U >
69 ptr_map( const ptr_map<Key,U>& r ) : base_type( r )
70 { }
71
72 ptr_map& operator=( ptr_map r )
73 {
74 this->swap( r );
75 return *this;
76 }
77 };
78
79
80
81 template
82 <
83 class Key,
84 class T,
85 class Compare = std::less<Key>,
86 class CloneAllocator = heap_clone_allocator,
87 class Allocator = std::allocator< std::pair<const Key,void*> >
88 >
89 class ptr_multimap :
90 public ptr_multimap_adapter<T,std::multimap<Key,void*,
91 Compare,Allocator>,CloneAllocator>
92 {
93 typedef ptr_multimap_adapter<T,std::multimap<Key,void*,
94 Compare,Allocator>,CloneAllocator>
95 base_type;
96
97 typedef ptr_multimap<Key,T,Compare,CloneAllocator,Allocator> this_type;
98
99 public:
100 ptr_multimap()
101 { }
102
103 explicit ptr_multimap( const Compare& comp,
104 const Allocator& a = Allocator() )
105 : base_type( comp, a ) { }
106
107 template< class InputIterator >
108 ptr_multimap( InputIterator first, InputIterator last )
109 : base_type( first, last )
110 { }
111
112 template< class InputIterator >
113 ptr_multimap( InputIterator first, InputIterator last,
114 const Compare& comp,
115 const Allocator& a = Allocator() )
116 : base_type( first, last, comp, a )
117 { }
118
119 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap,
120 base_type,
121 this_type )
122
123 template< class U >
124 ptr_multimap( const ptr_multimap<Key,U>& r ) : base_type( r )
125 { }
126
127 ptr_multimap& operator=( ptr_multimap r )
128 {
129 this->swap( r );
130 return *this;
131 }
132 };
133
134 //////////////////////////////////////////////////////////////////////////////
135 // clonability
136
137 template< class K, class T, class C, class CA, class A >
138 inline ptr_map<K,T,C,CA,A>* new_clone( const ptr_map<K,T,C,CA,A>& r )
139 {
140 return r.clone().release();
141 }
142
143 template< class K, class T, class C, class CA, class A >
144 inline ptr_multimap<K,T,C,CA,A>* new_clone( const ptr_multimap<K,T,C,CA,A>& r )
145 {
146 return r.clone().release();
147 }
148
149 /////////////////////////////////////////////////////////////////////////
150 // swap
151
152 template< typename K, typename T, typename C, typename CA, typename A >
153 inline void swap( ptr_map<K,T,C,CA,A>& l, ptr_map<K,T,C,CA,A>& r )
154 {
155 l.swap(r);
156 }
157
158 template< typename K, typename T, typename C, typename CA, typename A >
159 inline void swap( ptr_multimap<K,T,C,CA,A>& l, ptr_multimap<K,T,C,CA,A>& r )
160 {
161 l.swap(r);
162 }
163
164
165 }
166
167 #endif