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_SET_HPP
13#define BOOST_PTR_CONTAINER_PTR_SET_HPP
14
15#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16# pragma once
17#endif
18
19#include <boost/ptr_container/indirect_fun.hpp>
20#include <boost/ptr_container/ptr_set_adapter.hpp>
21#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
22#include <set>
23
24#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
25#pragma GCC diagnostic push
26#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
27#endif
28
29namespace boost
30{
31
32 template
33 <
34 class Key,
35 class Compare = std::less<Key>,
36 class CloneAllocator = heap_clone_allocator,
37 class Allocator = std::allocator<typename ptr_container_detail::void_ptr<Key>::type>
38 >
39 class ptr_set :
40 public ptr_set_adapter< Key, std::set<
41 typename ptr_container_detail::void_ptr<Key>::type,
42 void_ptr_indirect_fun<Compare,Key>,Allocator>,
43 CloneAllocator, true >
44 {
45 typedef ptr_set_adapter< Key, std::set<
46 typename ptr_container_detail::void_ptr<Key>::type,
47 void_ptr_indirect_fun<Compare,Key>,Allocator>,
48 CloneAllocator, true >
49 base_type;
50
51 typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
52
53 public:
54 ptr_set()
55 { }
56
57 explicit ptr_set( const Compare& comp,
58 const Allocator& a = Allocator() )
59 : base_type( comp, a )
60 { }
61
62 template< typename InputIterator >
63 ptr_set( InputIterator first, InputIterator last )
64 : base_type( first, last )
65 { }
66
67 template< typename InputIterator >
68 ptr_set( InputIterator first, InputIterator last,
69 const Compare& comp,
70 const Allocator& a = Allocator() )
71 : base_type( first, last, comp, a )
72 { }
73
74 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_set,
75 base_type,
76 this_type )
77
78 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_set, base_type )
79
80 };
81
82
83
84 template
85 <
86 class Key,
87 class Compare = std::less<Key>,
88 class CloneAllocator = heap_clone_allocator,
89 class Allocator = std::allocator<void*>
90 >
91 class ptr_multiset :
92 public ptr_multiset_adapter< Key,
93 std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
94 CloneAllocator, true >
95 {
96 typedef ptr_multiset_adapter< Key,
97 std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
98 CloneAllocator, true >
99 base_type;
100 typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
101
102 public:
103 ptr_multiset()
104 { }
105
106 explicit ptr_multiset( const Compare& comp,
107 const Allocator& a = Allocator() )
108 : base_type( comp, a )
109 { }
110
111 template< typename InputIterator >
112 ptr_multiset( InputIterator first, InputIterator last )
113 : base_type( first, last )
114 { }
115
116 template< typename InputIterator >
117 ptr_multiset( InputIterator first, InputIterator last,
118 const Compare& comp,
119 const Allocator& a = Allocator() )
120 : base_type( first, last, comp, a )
121 { }
122
123 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multiset,
124 base_type,
125 this_type )
126
127 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_multiset,
128 base_type )
129
130 };
131
132 /////////////////////////////////////////////////////////////////////////
133 // clonability
134
135 template< typename K, typename C, typename CA, typename A >
136 inline ptr_set<K,C,CA,A>* new_clone( const ptr_set<K,C,CA,A>& r )
137 {
138 return r.clone().release();
139 }
140
141 template< typename K, typename C, typename CA, typename A >
142 inline ptr_multiset<K,C,CA,A>* new_clone( const ptr_multiset<K,C,CA,A>& r )
143 {
144 return r.clone().release();
145 }
146
147 /////////////////////////////////////////////////////////////////////////
148 // swap
149
150 template< typename K, typename C, typename CA, typename A >
151 inline void swap( ptr_set<K,C,CA,A>& l, ptr_set<K,C,CA,A>& r )
152 {
153 l.swap(r);
154 }
155
156 template< typename K, typename C, typename CA, typename A >
157 inline void swap( ptr_multiset<K,C,CA,A>& l, ptr_multiset<K,C,CA,A>& r )
158 {
159 l.swap(r);
160 }
161
162}
163
164#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
165#pragma GCC diagnostic pop
166#endif
167
168#endif
169

source code of boost/libs/ptr_container/include/boost/ptr_container/ptr_set.hpp