fix doc example typo
[boost.git] / boost / ptr_container / ptr_set.hpp
blob74bfa4121056fcb4dca1e57cdbc9a71899bce8e6
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/
12 #ifndef BOOST_PTR_CONTAINER_PTR_SET_HPP
13 #define BOOST_PTR_CONTAINER_PTR_SET_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif
19 #include <boost/ptr_container/indirect_fun.hpp>
20 #include <boost/ptr_container/ptr_set_adapter.hpp>
21 #include <set>
23 namespace boost
26 template
28 class Key,
29 class Compare = std::less<Key>,
30 class CloneAllocator = heap_clone_allocator,
31 class Allocator = std::allocator<void*>
33 class ptr_set :
34 public ptr_set_adapter< Key,
35 std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
36 CloneAllocator, true >
38 typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
39 CloneAllocator, true >
40 base_type;
42 typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
44 public:
45 ptr_set()
46 { }
48 explicit ptr_set( const Compare& comp,
49 const Allocator& a = Allocator() )
50 : base_type( comp, a )
51 { }
53 template< typename InputIterator >
54 ptr_set( InputIterator first, InputIterator last )
55 : base_type( first, last )
56 { }
58 template< typename InputIterator >
59 ptr_set( InputIterator first, InputIterator last,
60 const Compare& comp,
61 const Allocator& a = Allocator() )
62 : base_type( first, last, comp, a )
63 { }
65 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_set,
66 base_type,
67 this_type )
69 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_set, base_type )
75 template
77 class Key,
78 class Compare = std::less<Key>,
79 class CloneAllocator = heap_clone_allocator,
80 class Allocator = std::allocator<void*>
82 class ptr_multiset :
83 public ptr_multiset_adapter< Key,
84 std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
85 CloneAllocator, true >
87 typedef ptr_multiset_adapter< Key,
88 std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
89 CloneAllocator, true >
90 base_type;
91 typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
93 public:
94 ptr_multiset()
95 { }
97 explicit ptr_multiset( const Compare& comp,
98 const Allocator& a = Allocator() )
99 : base_type( comp, a )
102 template< typename InputIterator >
103 ptr_multiset( InputIterator first, InputIterator last )
104 : base_type( first, last )
107 template< typename InputIterator >
108 ptr_multiset( InputIterator first, InputIterator last,
109 const Compare& comp,
110 const Allocator& a = Allocator() )
111 : base_type( first, last, comp, a )
114 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multiset,
115 base_type,
116 this_type )
118 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_multiset,
119 base_type )
123 /////////////////////////////////////////////////////////////////////////
124 // clonability
126 template< typename K, typename C, typename CA, typename A >
127 inline ptr_set<K,C,CA,A>* new_clone( const ptr_set<K,C,CA,A>& r )
129 return r.clone().release();
132 template< typename K, typename C, typename CA, typename A >
133 inline ptr_multiset<K,C,CA,A>* new_clone( const ptr_multiset<K,C,CA,A>& r )
135 return r.clone().release();
138 /////////////////////////////////////////////////////////////////////////
139 // swap
141 template< typename K, typename C, typename CA, typename A >
142 inline void swap( ptr_set<K,C,CA,A>& l, ptr_set<K,C,CA,A>& r )
144 l.swap(r);
147 template< typename K, typename C, typename CA, typename A >
148 inline void swap( ptr_multiset<K,C,CA,A>& l, ptr_multiset<K,C,CA,A>& r )
150 l.swap(r);
155 #endif