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
,void*> >
34 public ptr_map_adapter
<T
,std::map
<Key
,void*,
35 Compare
,Allocator
>,CloneAllocator
>
37 typedef ptr_map_adapter
<T
,std::map
<Key
,void*,
38 Compare
,Allocator
>,CloneAllocator
>
41 typedef ptr_map
<Key
,T
,Compare
,CloneAllocator
,Allocator
> this_type
;
47 explicit ptr_map( const Compare
& comp
,
48 const Allocator
& a
= Allocator() )
49 : base_type( comp
, a
) { }
51 template< class InputIterator
>
52 ptr_map( InputIterator first
, InputIterator last
)
53 : base_type( first
, last
)
56 template< class InputIterator
>
57 ptr_map( InputIterator first
, InputIterator last
,
59 const Allocator
& a
= Allocator() )
60 : base_type( first
, last
, comp
, a
)
63 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map
, base_type
,
67 ptr_map( const ptr_map
<Key
,U
>& r
) : base_type( r
)
70 ptr_map
& operator=( ptr_map r
)
83 class Compare
= std::less
<Key
>,
84 class CloneAllocator
= heap_clone_allocator
,
85 class Allocator
= std::allocator
< std::pair
<const Key
,void*> >
88 public ptr_multimap_adapter
<T
,std::multimap
<Key
,void*,
89 Compare
,Allocator
>,CloneAllocator
>
91 typedef ptr_multimap_adapter
<T
,std::multimap
<Key
,void*,
92 Compare
,Allocator
>,CloneAllocator
>
95 typedef ptr_multimap
<Key
,T
,Compare
,CloneAllocator
,Allocator
> this_type
;
101 explicit ptr_multimap( const Compare
& comp
,
102 const Allocator
& a
= Allocator() )
103 : base_type( comp
, a
) { }
105 template< class InputIterator
>
106 ptr_multimap( InputIterator first
, InputIterator last
)
107 : base_type( first
, last
)
110 template< class InputIterator
>
111 ptr_multimap( InputIterator first
, InputIterator last
,
113 const Allocator
& a
= Allocator() )
114 : base_type( first
, last
, comp
, a
)
117 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap
,
122 ptr_multimap( const ptr_multimap
<Key
,U
>& r
) : base_type( r
)
125 ptr_multimap
& operator=( ptr_multimap r
)
132 //////////////////////////////////////////////////////////////////////////////
135 template< class K
, class T
, class C
, class CA
, class A
>
136 inline ptr_map
<K
,T
,C
,CA
,A
>* new_clone( const ptr_map
<K
,T
,C
,CA
,A
>& r
)
138 return r
.clone().release();
141 template< class K
, class T
, class C
, class CA
, class A
>
142 inline ptr_multimap
<K
,T
,C
,CA
,A
>* new_clone( const ptr_multimap
<K
,T
,C
,CA
,A
>& r
)
144 return r
.clone().release();
147 /////////////////////////////////////////////////////////////////////////
150 template< typename K
, typename T
, typename C
, typename CA
, typename A
>
151 inline void swap( ptr_map
<K
,T
,C
,CA
,A
>& l
, ptr_map
<K
,T
,C
,CA
,A
>& r
)
156 template< typename K
, typename T
, typename C
, typename CA
, typename A
>
157 inline void swap( ptr_multimap
<K
,T
,C
,CA
,A
>& l
, ptr_multimap
<K
,T
,C
,CA
,A
>& r
)