2 // Boost.Pointer Container
4 // Copyright Thorsten Ottosen 2008. 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)
9 // For more information, see http://www.boost.org/libs/ptr_container/
12 #ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
13 #define BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/unordered_map.hpp>
20 #include <boost/ptr_container/ptr_map_adapter.hpp>
21 #include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
23 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
24 #pragma GCC diagnostic push
25 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
35 class Hash = boost::hash<Key>,
36 class Pred = std::equal_to<Key>,
37 class CloneAllocator = heap_clone_allocator,
38 class Allocator = std::allocator< std::pair<const Key,
39 typename ptr_container_detail::void_ptr<T>::type> >
41 class ptr_unordered_map :
42 public ptr_map_adapter<T,boost::unordered_map<Key,
43 typename ptr_container_detail::void_ptr<T>::type,Hash,Pred,Allocator>,
46 typedef ptr_map_adapter<T,boost::unordered_map<Key,
47 typename ptr_container_detail::void_ptr<T>::type,Hash,Pred,Allocator>,
51 typedef ptr_unordered_map<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
54 typedef typename base_type::size_type size_type;
57 using base_type::lower_bound;
58 using base_type::upper_bound;
59 using base_type::rbegin;
60 using base_type::rend;
61 using base_type::crbegin;
62 using base_type::crend;
63 using base_type::key_comp;
64 using base_type::value_comp;
65 using base_type::front;
66 using base_type::back;
69 using base_type::begin;
71 using base_type::cbegin;
72 using base_type::cend;
73 using base_type::bucket_count;
74 using base_type::max_bucket_count;
75 using base_type::bucket_size;
76 using base_type::bucket;
77 using base_type::load_factor;
78 using base_type::max_load_factor;
79 using base_type::rehash;
80 using base_type::key_eq;
81 using base_type::hash_function;
87 explicit ptr_unordered_map( size_type n )
88 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
91 ptr_unordered_map( size_type n,
93 const Pred& pred = Pred(),
94 const Allocator& a = Allocator() )
95 : base_type( n, comp, pred, a )
98 template< typename InputIterator >
99 ptr_unordered_map( InputIterator first, InputIterator last )
100 : base_type( first, last )
103 template< typename InputIterator >
104 ptr_unordered_map( InputIterator first, InputIterator last,
106 const Pred& pred = Pred(),
107 const Allocator& a = Allocator() )
108 : base_type( first, last, comp, pred, a )
111 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_map,
116 ptr_unordered_map( const ptr_unordered_map<Key,U>& r ) : base_type( r )
119 ptr_unordered_map& operator=( ptr_unordered_map r )
132 class Hash = boost::hash<Key>,
133 class Pred = std::equal_to<Key>,
134 class CloneAllocator = heap_clone_allocator,
135 class Allocator = std::allocator< std::pair<const Key,void*> >
137 class ptr_unordered_multimap :
138 public ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
139 CloneAllocator,false>
141 typedef ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
142 CloneAllocator,false>
145 typedef ptr_unordered_multimap<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
148 typedef typename base_type::size_type size_type;
151 using base_type::lower_bound;
152 using base_type::upper_bound;
153 using base_type::rbegin;
154 using base_type::rend;
155 using base_type::crbegin;
156 using base_type::crend;
157 using base_type::key_comp;
158 using base_type::value_comp;
159 using base_type::front;
160 using base_type::back;
163 using base_type::begin;
164 using base_type::end;
165 using base_type::cbegin;
166 using base_type::cend;
167 using base_type::bucket_count;
168 using base_type::max_bucket_count;
169 using base_type::bucket_size;
170 using base_type::bucket;
171 using base_type::load_factor;
172 using base_type::max_load_factor;
173 using base_type::rehash;
174 using base_type::key_eq;
175 using base_type::hash_function;
178 ptr_unordered_multimap()
181 explicit ptr_unordered_multimap( size_type n )
182 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
185 ptr_unordered_multimap( size_type n,
187 const Pred& pred = Pred(),
188 const Allocator& a = Allocator() )
189 : base_type( n, comp, pred, a )
192 template< typename InputIterator >
193 ptr_unordered_multimap( InputIterator first, InputIterator last )
194 : base_type( first, last )
197 template< typename InputIterator >
198 ptr_unordered_multimap( InputIterator first, InputIterator last,
200 const Pred& pred = Pred(),
201 const Allocator& a = Allocator() )
202 : base_type( first, last, comp, pred, a )
205 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multimap,
210 ptr_unordered_multimap( const ptr_unordered_multimap<Key,U>& r ) : base_type( r )
213 ptr_unordered_multimap& operator=( ptr_unordered_multimap r )
220 //////////////////////////////////////////////////////////////////////////////
223 template< class K, class T, class H, class P, class CA, class A >
224 inline ptr_unordered_map<K,T,H,P,CA,A>*
225 new_clone( const ptr_unordered_map<K,T,H,P,CA,A>& r )
227 return r.clone().release();
230 template< class K, class T, class H, class P, class CA, class A >
231 inline ptr_unordered_multimap<K,T,H,P,CA,A>*
232 new_clone( const ptr_unordered_multimap<K,T,H,P,CA,A>& r )
234 return r.clone().release();
237 /////////////////////////////////////////////////////////////////////////
240 template< class K, class T, class H, class P, class CA, class A >
241 inline void swap( ptr_unordered_map<K,T,H,P,CA,A>& l,
242 ptr_unordered_map<K,T,H,P,CA,A>& r )
247 template< class K, class T, class H, class P, class CA, class A >
248 inline void swap( ptr_unordered_multimap<K,T,H,P,CA,A>& l,
249 ptr_unordered_multimap<K,T,H,P,CA,A>& r )
257 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
258 #pragma GCC diagnostic pop