Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/ptr_container/ptr_map.hpp @ 44

Last change on this file since 44 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

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