2 // Boost.Pointer Container
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)
9 // For more information, see http://www.boost.org/libs/ptr_container/
12 #ifndef BOOST_PTR_CONTAINER_PTR_MAP_HPP
13 #define BOOST_PTR_CONTAINER_PTR_MAP_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
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 Compare = std::less<Key>,
36 class CloneAllocator = heap_clone_allocator,
37 class Allocator = std::allocator< std::pair<const Key,typename ptr_container_detail::void_ptr<T>::type> >
40 public ptr_map_adapter<T,std::map<Key,
41 typename ptr_container_detail::void_ptr<T>::type,
42 Compare,Allocator>,CloneAllocator>
44 typedef ptr_map_adapter<T,std::map<Key,
45 typename ptr_container_detail::void_ptr<T>::type,
46 Compare,Allocator>,CloneAllocator>
49 typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
55 explicit ptr_map( const Compare& comp,
56 const Allocator& a = Allocator() )
57 : base_type( comp, a ) { }
59 template< class InputIterator >
60 ptr_map( InputIterator first, InputIterator last )
61 : base_type( first, last )
64 template< class InputIterator >
65 ptr_map( InputIterator first, InputIterator last,
67 const Allocator& a = Allocator() )
68 : base_type( first, last, comp, a )
71 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map, base_type,
75 ptr_map( const ptr_map<Key,U>& r ) : base_type( r )
78 ptr_map& operator=( ptr_map r )
91 class Compare = std::less<Key>,
92 class CloneAllocator = heap_clone_allocator,
93 class Allocator = std::allocator< std::pair<const Key,void*> >
96 public ptr_multimap_adapter<T,std::multimap<Key,void*,
97 Compare,Allocator>,CloneAllocator>
99 typedef ptr_multimap_adapter<T,std::multimap<Key,void*,
100 Compare,Allocator>,CloneAllocator>
103 typedef ptr_multimap<Key,T,Compare,CloneAllocator,Allocator> this_type;
109 explicit ptr_multimap( const Compare& comp,
110 const Allocator& a = Allocator() )
111 : base_type( comp, a ) { }
113 template< class InputIterator >
114 ptr_multimap( InputIterator first, InputIterator last )
115 : base_type( first, last )
118 template< class InputIterator >
119 ptr_multimap( InputIterator first, InputIterator last,
121 const Allocator& a = Allocator() )
122 : base_type( first, last, comp, a )
125 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap,
130 ptr_multimap( const ptr_multimap<Key,U>& r ) : base_type( r )
133 ptr_multimap& operator=( ptr_multimap r )
140 //////////////////////////////////////////////////////////////////////////////
143 template< class K, class T, class C, class CA, class A >
144 inline ptr_map<K,T,C,CA,A>* new_clone( const ptr_map<K,T,C,CA,A>& r )
146 return r.clone().release();
149 template< class K, class T, class C, class CA, class A >
150 inline ptr_multimap<K,T,C,CA,A>* new_clone( const ptr_multimap<K,T,C,CA,A>& r )
152 return r.clone().release();
155 /////////////////////////////////////////////////////////////////////////
158 template< typename K, typename T, typename C, typename CA, typename A >
159 inline void swap( ptr_map<K,T,C,CA,A>& l, ptr_map<K,T,C,CA,A>& r )
164 template< typename K, typename T, typename C, typename CA, typename A >
165 inline void swap( ptr_multimap<K,T,C,CA,A>& l, ptr_multimap<K,T,C,CA,A>& r )
173 #if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
174 #pragma GCC diagnostic pop