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>
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> >
34 public ptr_map_adapter<T,std::map<Key,
35 typename ptr_container_detail::void_ptr<T>::type,
36 Compare,Allocator>,CloneAllocator>
38 typedef ptr_map_adapter<T,std::map<Key,
39 typename ptr_container_detail::void_ptr<T>::type,
40 Compare,Allocator>,CloneAllocator>
43 typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
49 explicit ptr_map( const Compare& comp,
50 const Allocator& a = Allocator() )
51 : base_type( comp, a ) { }
53 template< class InputIterator >
54 ptr_map( InputIterator first, InputIterator last )
55 : base_type( first, last )
58 template< class InputIterator >
59 ptr_map( InputIterator first, InputIterator last,
61 const Allocator& a = Allocator() )
62 : base_type( first, last, comp, a )
65 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map, base_type,
69 ptr_map( const ptr_map<Key,U>& r ) : base_type( r )
72 ptr_map& operator=( ptr_map r )
85 class Compare = std::less<Key>,
86 class CloneAllocator = heap_clone_allocator,
87 class Allocator = std::allocator< std::pair<const Key,void*> >
90 public ptr_multimap_adapter<T,std::multimap<Key,void*,
91 Compare,Allocator>,CloneAllocator>
93 typedef ptr_multimap_adapter<T,std::multimap<Key,void*,
94 Compare,Allocator>,CloneAllocator>
97 typedef ptr_multimap<Key,T,Compare,CloneAllocator,Allocator> this_type;
103 explicit ptr_multimap( const Compare& comp,
104 const Allocator& a = Allocator() )
105 : base_type( comp, a ) { }
107 template< class InputIterator >
108 ptr_multimap( InputIterator first, InputIterator last )
109 : base_type( first, last )
112 template< class InputIterator >
113 ptr_multimap( InputIterator first, InputIterator last,
115 const Allocator& a = Allocator() )
116 : base_type( first, last, comp, a )
119 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap,
124 ptr_multimap( const ptr_multimap<Key,U>& r ) : base_type( r )
127 ptr_multimap& operator=( ptr_multimap r )
134 //////////////////////////////////////////////////////////////////////////////
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 )
140 return r.clone().release();
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 )
146 return r.clone().release();
149 /////////////////////////////////////////////////////////////////////////
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 )
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 )