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,void*> >
|
---|
32 | >
|
---|
33 | class ptr_map :
|
---|
34 | public ptr_map_adapter<T,std::map<Key,void*,Compare,Allocator>,CloneAllocator>
|
---|
35 | {
|
---|
36 | typedef ptr_map_adapter<T,std::map<Key,void*,Compare,Allocator>,CloneAllocator>
|
---|
37 | base_type;
|
---|
38 |
|
---|
39 | typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
|
---|
40 |
|
---|
41 | public:
|
---|
42 | explicit ptr_map( const Compare& comp = Compare(),
|
---|
43 | const Allocator& a = Allocator() )
|
---|
44 | : base_type( comp, a ) { }
|
---|
45 |
|
---|
46 | template< class InputIterator >
|
---|
47 | ptr_map( InputIterator first, InputIterator last,
|
---|
48 | const Compare& comp = Compare(),
|
---|
49 | const Allocator& a = Allocator() )
|
---|
50 | : base_type( first, last, comp, a )
|
---|
51 | { }
|
---|
52 |
|
---|
53 | BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map, base_type,
|
---|
54 | this_type );
|
---|
55 |
|
---|
56 | };
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | template
|
---|
61 | <
|
---|
62 | class Key,
|
---|
63 | class T,
|
---|
64 | class Compare = std::less<Key>,
|
---|
65 | class CloneAllocator = heap_clone_allocator,
|
---|
66 | class Allocator = std::allocator< std::pair<const Key,void*> >
|
---|
67 | >
|
---|
68 | class ptr_multimap :
|
---|
69 | public ptr_multimap_adapter<T,std::multimap<Key,void*,Compare,Allocator>,CloneAllocator>
|
---|
70 | {
|
---|
71 | typedef ptr_multimap_adapter<T,std::multimap<Key,void*,Compare,Allocator>,CloneAllocator>
|
---|
72 | base_type;
|
---|
73 |
|
---|
74 | typedef ptr_multimap<Key,T,Compare,CloneAllocator,Allocator> this_type;
|
---|
75 |
|
---|
76 | public:
|
---|
77 | explicit ptr_multimap( const Compare& comp = Compare(),
|
---|
78 | const Allocator& a = Allocator() )
|
---|
79 | : base_type( comp, a ) { }
|
---|
80 |
|
---|
81 | template< class InputIterator >
|
---|
82 | ptr_multimap( InputIterator first, InputIterator last,
|
---|
83 | const Compare& comp = Compare(),
|
---|
84 | const Allocator& a = Allocator() )
|
---|
85 | : base_type( first, last, comp, a )
|
---|
86 | { }
|
---|
87 |
|
---|
88 | BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap,
|
---|
89 | base_type,
|
---|
90 | this_type );
|
---|
91 |
|
---|
92 | };
|
---|
93 |
|
---|
94 | //////////////////////////////////////////////////////////////////////////////
|
---|
95 | // clonability
|
---|
96 |
|
---|
97 | template< class K, class T, class C, class CA, class A >
|
---|
98 | inline ptr_map<K,T,C,CA,A>* new_clone( const ptr_map<K,T,C,CA,A>& r )
|
---|
99 | {
|
---|
100 | return r.clone().release();
|
---|
101 | }
|
---|
102 |
|
---|
103 | template< class K, class T, class C, class CA, class A >
|
---|
104 | inline ptr_multimap<K,T,C,CA,A>* new_clone( const ptr_multimap<K,T,C,CA,A>& r )
|
---|
105 | {
|
---|
106 | return r.clone().release();
|
---|
107 | }
|
---|
108 |
|
---|
109 | /////////////////////////////////////////////////////////////////////////
|
---|
110 | // swap
|
---|
111 |
|
---|
112 | template< typename K, typename T, typename C, typename CA, typename A >
|
---|
113 | inline void swap( ptr_map<K,T,C,CA,A>& l, ptr_map<K,T,C,CA,A>& r )
|
---|
114 | {
|
---|
115 | l.swap(r);
|
---|
116 | }
|
---|
117 |
|
---|
118 | template< typename K, typename T, typename C, typename CA, typename A >
|
---|
119 | inline void swap( ptr_multimap<K,T,C,CA,A>& l, ptr_multimap<K,T,C,CA,A>& r )
|
---|
120 | {
|
---|
121 | l.swap(r);
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | }
|
---|
126 |
|
---|
127 | #endif
|
---|