source: NonGTP/Boost/boost/ptr_container/ptr_set.hpp @ 857

Revision 857, 4.4 KB checked in by igarcia, 18 years ago (diff)
Line 
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 <set>
22
23namespace boost
24{
25
26    template
27    <
28        class Key,
29        class Compare        = std::less<Key>,
30        class CloneAllocator = heap_clone_allocator,
31        class Allocator      = std::allocator<void*>
32    >
33    class ptr_set :
34        public ptr_set_adapter< Key,
35                                std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
36                                CloneAllocator >
37    {
38        typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
39                                 CloneAllocator >
40             base_type;
41
42        typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
43       
44    public:
45        explicit ptr_set( const Compare& comp = Compare(),
46                          const Allocator& a = Allocator() )
47         : base_type( comp, a )
48        { }
49       
50        template< typename InputIterator >
51        ptr_set( InputIterator first, InputIterator last,
52                 const Compare& comp = Compare(),
53                 const Allocator& a = Allocator() )
54         : base_type( first, last, comp, a )
55        { }
56
57        BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_set,
58                                                      base_type,
59                                                      this_type );
60
61    };
62       
63       
64       
65    template
66    <
67        class Key,
68        class Compare        = std::less<Key>,
69        class CloneAllocator = heap_clone_allocator,
70        class Allocator      = std::allocator<void*>
71    >
72    class ptr_multiset :
73        public ptr_multiset_adapter< Key,
74                                     std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
75                                     CloneAllocator >
76    {
77        typedef ptr_multiset_adapter< Key,
78                                      std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
79                                      CloneAllocator >
80              base_type;
81        typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
82       
83    public:
84        explicit ptr_multiset( const Compare&   comp = Compare(),
85                               const Allocator& a    = Allocator() )
86         : base_type( comp, a )
87        { }
88       
89        template< typename InputIterator >
90        ptr_multiset( InputIterator first, InputIterator last,
91                      const Compare& comp = Compare(),
92                      const Allocator& a  = Allocator() )
93         : base_type( first, last, comp, a )
94        { }
95
96        BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multiset,
97                                                      base_type,
98                                                      this_type );       
99
100    };
101
102    /////////////////////////////////////////////////////////////////////////
103    // clonability
104
105    template< typename K, typename C, typename CA, typename A >
106    inline ptr_set<K,C,CA,A>* new_clone( const ptr_set<K,C,CA,A>& r )
107    {
108        return r.clone().release();
109    }
110
111    template< typename K, typename C, typename CA, typename A >
112    inline ptr_multiset<K,C,CA,A>* new_clone( const ptr_multiset<K,C,CA,A>& r )
113    {
114        return r.clone().release();
115    }
116   
117    /////////////////////////////////////////////////////////////////////////
118    // swap
119
120    template< typename K, typename C, typename CA, typename A >
121    inline void swap( ptr_set<K,C,CA,A>& l, ptr_set<K,C,CA,A>& r )
122    {
123        l.swap(r);
124    }
125
126    template< typename K, typename C, typename CA, typename A >
127    inline void swap( ptr_multiset<K,C,CA,A>& l, ptr_multiset<K,C,CA,A>& r )
128    {
129        l.swap(r);
130    }
131
132}
133
134#endif
Note: See TracBrowser for help on using the repository browser.