// // Boost.Pointer Container // // Copyright Thorsten Ottosen 2003-2005. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // For more information, see http://www.boost.org/libs/ptr_container/ // #ifndef BOOST_PTR_CONTAINER_PTR_MAP_HPP #define BOOST_PTR_CONTAINER_PTR_MAP_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include #include namespace boost { template < class Key, class T, class Compare = std::less, class CloneAllocator = heap_clone_allocator, class Allocator = std::allocator< std::pair > > class ptr_map : public ptr_map_adapter,CloneAllocator> { typedef ptr_map_adapter,CloneAllocator> base_type; typedef ptr_map this_type; public: explicit ptr_map( const Compare& comp = Compare(), const Allocator& a = Allocator() ) : base_type( comp, a ) { } template< class InputIterator > ptr_map( InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& a = Allocator() ) : base_type( first, last, comp, a ) { } BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map, base_type, this_type ); template< class U > ptr_map( const ptr_map& r ) : base_type( r ) { } template< class U > ptr_map& operator=( const ptr_map& r ) { base_type::operator=( r ); return *this; } }; template < class Key, class T, class Compare = std::less, class CloneAllocator = heap_clone_allocator, class Allocator = std::allocator< std::pair > > class ptr_multimap : public ptr_multimap_adapter,CloneAllocator> { typedef ptr_multimap_adapter,CloneAllocator> base_type; typedef ptr_multimap this_type; public: explicit ptr_multimap( const Compare& comp = Compare(), const Allocator& a = Allocator() ) : base_type( comp, a ) { } template< class InputIterator > ptr_multimap( InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& a = Allocator() ) : base_type( first, last, comp, a ) { } BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap, base_type, this_type ); template< class U > ptr_multimap( const ptr_multimap& r ) : base_type( r ) { } template< class U > ptr_multimap& operator=( const ptr_multimap& r ) { base_type::operator=( r ); return *this; } }; ////////////////////////////////////////////////////////////////////////////// // clonability template< class K, class T, class C, class CA, class A > inline ptr_map* new_clone( const ptr_map& r ) { return r.clone().release(); } template< class K, class T, class C, class CA, class A > inline ptr_multimap* new_clone( const ptr_multimap& r ) { return r.clone().release(); } ///////////////////////////////////////////////////////////////////////// // swap template< typename K, typename T, typename C, typename CA, typename A > inline void swap( ptr_map& l, ptr_map& r ) { l.swap(r); } template< typename K, typename T, typename C, typename CA, typename A > inline void swap( ptr_multimap& l, ptr_multimap& r ) { l.swap(r); } } #endif