epoc32/include/stdapis/boost/ptr_container/ptr_map_adapter.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/ptr_container/ptr_map_adapter.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,682 @@
     1.4 +//
     1.5 +// Boost.Pointer Container
     1.6 +//
     1.7 +//  Copyright Thorsten Ottosen 2003-2005. Use, modification and
     1.8 +//  distribution is subject to the Boost Software License, Version
     1.9 +//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
    1.10 +//  http://www.boost.org/LICENSE_1_0.txt)
    1.11 +//
    1.12 +// For more information, see http://www.boost.org/libs/ptr_container/
    1.13 +//
    1.14 +
    1.15 +#ifndef BOOST_PTR_CONTAINER_DETAIL_PTR_MAP_ADAPTER_HPP
    1.16 +#define BOOST_PTR_CONTAINER_DETAIL_PTR_MAP_ADAPTER_HPP
    1.17 +
    1.18 +#if defined(_MSC_VER) && (_MSC_VER >= 1200)
    1.19 +# pragma once
    1.20 +#endif
    1.21 +
    1.22 +#include <boost/ptr_container/detail/map_iterator.hpp>
    1.23 +#include <boost/ptr_container/detail/associative_ptr_container.hpp>
    1.24 +#include <boost/static_assert.hpp>
    1.25 +#include <boost/range/iterator_range.hpp>
    1.26 +
    1.27 +namespace boost
    1.28 +{
    1.29 +namespace ptr_container_detail
    1.30 +{
    1.31 +
    1.32 +    template
    1.33 +    < 
    1.34 +        class T,
    1.35 +        class VoidPtrMap
    1.36 +    >
    1.37 +    struct map_config
    1.38 +    {
    1.39 +        typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type
    1.40 +                     U;
    1.41 +        typedef VoidPtrMap 
    1.42 +                     void_container_type;
    1.43 +        
    1.44 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type
    1.45 +                     allocator_type;
    1.46 +        
    1.47 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::key_compare
    1.48 +                     key_compare;
    1.49 +        
    1.50 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::value_compare
    1.51 +                     value_compare;
    1.52 +        
    1.53 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::key_type
    1.54 +                     key_type;
    1.55 +        
    1.56 +        typedef U    value_type;
    1.57 +
    1.58 +        typedef ptr_map_iterator< BOOST_DEDUCED_TYPENAME VoidPtrMap::iterator, key_type, U* const >
    1.59 +                     iterator;
    1.60 +        
    1.61 +        typedef ptr_map_iterator< BOOST_DEDUCED_TYPENAME VoidPtrMap::const_iterator, key_type, const U* const>
    1.62 +                     const_iterator;
    1.63 +  
    1.64 +        template< class Iter >
    1.65 +        static U* get_pointer( Iter i )
    1.66 +        {
    1.67 +            return i->second;
    1.68 +        }
    1.69 +
    1.70 +        template< class Iter >
    1.71 +        static const U* get_const_pointer( Iter i )
    1.72 +        {
    1.73 +            return i->second;
    1.74 +        }
    1.75 +
    1.76 +        BOOST_STATIC_CONSTANT( bool, allow_null = boost::is_nullable<T>::value );
    1.77 +    };
    1.78 +    
    1.79 +    
    1.80 +
    1.81 +    template
    1.82 +    < 
    1.83 +        class T,
    1.84 +        class VoidPtrMap, 
    1.85 +        class CloneAllocator
    1.86 +    >
    1.87 +    class ptr_map_adapter_base : 
    1.88 +        public ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap>,
    1.89 +                                                    CloneAllocator >
    1.90 +    {
    1.91 +        typedef ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap>,
    1.92 +                                                     CloneAllocator > 
    1.93 +            base_type;
    1.94 +
    1.95 +        typedef map_config<T,VoidPtrMap>                           config;
    1.96 +
    1.97 +        typedef ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator>  this_type;
    1.98 +        
    1.99 +    public:
   1.100 +
   1.101 +        typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type
   1.102 +                    allocator_type;
   1.103 +        typedef BOOST_DEDUCED_TYPENAME base_type::iterator
   1.104 +                    iterator;
   1.105 +        typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
   1.106 +                    const_iterator;
   1.107 +        typedef BOOST_DEDUCED_TYPENAME base_type::size_type
   1.108 +                    size_type;
   1.109 +        typedef BOOST_DEDUCED_TYPENAME base_type::key_type
   1.110 +                    key_type;
   1.111 +        typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
   1.112 +                    auto_type;
   1.113 +        typedef BOOST_DEDUCED_TYPENAME base_type::value_type 
   1.114 +                    mapped_type;
   1.115 +        typedef BOOST_DEDUCED_TYPENAME base_type::reference
   1.116 +                    mapped_reference;
   1.117 +        typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
   1.118 +                    const_mapped_reference;
   1.119 +        typedef BOOST_DEDUCED_TYPENAME iterator_value<iterator>::type
   1.120 +                    value_type;
   1.121 +        typedef value_type
   1.122 +                    reference;
   1.123 +        typedef BOOST_DEDUCED_TYPENAME iterator_value<const_iterator>::type
   1.124 +                    const_reference;
   1.125 +        typedef value_type 
   1.126 +                    pointer;
   1.127 +        typedef const_reference 
   1.128 +                    const_pointer;
   1.129 +
   1.130 +    private:
   1.131 +        const_mapped_reference lookup( const key_type& key ) const
   1.132 +        {
   1.133 +           const_iterator i = this->find( key );
   1.134 +           if( i != this->end() )
   1.135 +               return *i->second;
   1.136 +           else                                           
   1.137 +               BOOST_PTR_CONTAINER_THROW_EXCEPTION( true, bad_ptr_container_operation,
   1.138 +                                                    "'ptr_map/multimap::at()' could"
   1.139 +                                                    " not find key" );
   1.140 +        }
   1.141 +
   1.142 +        struct eraser // scope guard
   1.143 +        {
   1.144 +            bool            released_;
   1.145 +            VoidPtrMap*     m_;
   1.146 +            const key_type& key_;
   1.147 +
   1.148 +            eraser( VoidPtrMap* m, const key_type& key ) 
   1.149 +              : released_(false), m_(m), key_(key)
   1.150 +            {}
   1.151 +
   1.152 +            ~eraser() 
   1.153 +            {
   1.154 +                if( !released_ )
   1.155 +                    m_->erase(key_);
   1.156 +            }
   1.157 +
   1.158 +            void release() { released_ = true; }
   1.159 +        };
   1.160 +
   1.161 +        mapped_reference insert_lookup( const key_type& key )
   1.162 +        {
   1.163 +            void*& ref = this->c_private()[key];
   1.164 +            if( ref )
   1.165 +            {
   1.166 +                return *static_cast<mapped_type>(ref);
   1.167 +            }
   1.168 +            else
   1.169 +            {
   1.170 +                eraser e(&this->c_private(),key); // nothrow
   1.171 +                mapped_type res = new T();        // strong 
   1.172 +                ref = res;                        // nothrow
   1.173 +                e.release();                      // nothrow
   1.174 +                return *res;
   1.175 +            }
   1.176 +          }
   1.177 +        
   1.178 +    public:
   1.179 +
   1.180 +        ptr_map_adapter_base( const allocator_type& a = allocator_type() )
   1.181 +        : base_type(a)
   1.182 +        { }
   1.183 +
   1.184 +        template< class InputIterator >
   1.185 +        ptr_map_adapter_base( InputIterator first, InputIterator last,
   1.186 +                              const allocator_type& a = allocator_type() )
   1.187 +        : base_type( first, last, a )
   1.188 +        { }
   1.189 + 
   1.190 +        template< class Compare, class Allocator >
   1.191 +        explicit ptr_map_adapter_base( const Compare& comp,
   1.192 +                                       const Allocator& a ) 
   1.193 +        : base_type( comp, a ) 
   1.194 +        { }
   1.195 +
   1.196 +        template< class PtrContainer >
   1.197 +        ptr_map_adapter_base( std::auto_ptr<PtrContainer> clone ) 
   1.198 +        : base_type( clone )
   1.199 +        { }
   1.200 +        
   1.201 +        template< typename PtrContainer >
   1.202 +        void operator=( std::auto_ptr<PtrContainer> clone )    
   1.203 +        {
   1.204 +            base_type::operator=( clone );
   1.205 +        }        
   1.206 +
   1.207 +        iterator find( const key_type& x )                                                
   1.208 +        {                                                                            
   1.209 +            return iterator( this->c_private().find( x ) );                                
   1.210 +        }                                                                            
   1.211 +
   1.212 +        const_iterator find( const key_type& x ) const                                    
   1.213 +        {                                                                            
   1.214 +            return const_iterator( this->c_private().find( x ) );                          
   1.215 +        }                                                                            
   1.216 +
   1.217 +        size_type count( const key_type& x ) const                                        
   1.218 +        {                                                                            
   1.219 +            return this->c_private().count( x );                                           
   1.220 +        }                                                                            
   1.221 +                                                                                     
   1.222 +        iterator lower_bound( const key_type& x )                                         
   1.223 +        {                                                                            
   1.224 +            return iterator( this->c_private().lower_bound( x ) );                         
   1.225 +        }                                                                            
   1.226 +                                                                                     
   1.227 +        const_iterator lower_bound( const key_type& x ) const                             
   1.228 +        {                                                                            
   1.229 +            return const_iterator( this->c_private().lower_bound( x ) );                   
   1.230 +        }                                                                            
   1.231 +                                                                                     
   1.232 +        iterator upper_bound( const key_type& x )                                         
   1.233 +        {                                                                            
   1.234 +            return iterator( this->c_private().upper_bound( x ) );                         
   1.235 +        }                                                                            
   1.236 +                                                                                     
   1.237 +        const_iterator upper_bound( const key_type& x ) const                             
   1.238 +        {                                                                            
   1.239 +            return const_iterator( this->c_private().upper_bound( x ) );                   
   1.240 +        }                                                                            
   1.241 +                                                                                     
   1.242 +        iterator_range<iterator> equal_range( const key_type& x )                    
   1.243 +        {                                                                            
   1.244 +            std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,
   1.245 +                      BOOST_DEDUCED_TYPENAME base_type::ptr_iterator>
   1.246 +                 p = this->c_private().equal_range( x );   
   1.247 +            return make_iterator_range( iterator( p.first ), iterator( p.second ) );      
   1.248 +        }                                                                            
   1.249 +                                                                                     
   1.250 +        iterator_range<const_iterator> equal_range( const key_type& x ) const  
   1.251 +        {                                                                            
   1.252 +            std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator,
   1.253 +                      BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator> 
   1.254 +                p = this->c_private().equal_range( x ); 
   1.255 +            return make_iterator_range( const_iterator( p.first ), 
   1.256 +                                        const_iterator( p.second ) );    
   1.257 +        }                                                                            
   1.258 +                                                                                     
   1.259 +        mapped_reference at( const key_type& key )  
   1.260 +        {   
   1.261 +            return const_cast<mapped_reference>( lookup( key ) ); 
   1.262 +        }
   1.263 +                                                                                     
   1.264 +        const_mapped_reference at( const key_type& key ) const
   1.265 +        {                                                                            
   1.266 +            return lookup( key );
   1.267 +        }
   1.268 +
   1.269 +        mapped_reference operator[]( const key_type& key )
   1.270 +        {
   1.271 +            return insert_lookup( key );
   1.272 +        }              
   1.273 +
   1.274 +        auto_type replace( iterator where, mapped_type x ) // strong  
   1.275 +        { 
   1.276 +            BOOST_ASSERT( where != this->end() );
   1.277 +
   1.278 +            this->enforce_null_policy( x, "Null pointer in 'replace()'" );
   1.279 +
   1.280 +            auto_type ptr( x );
   1.281 +
   1.282 +            BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
   1.283 +                                                 bad_ptr_container_operation,
   1.284 +                                                 "'replace()' on empty container" );
   1.285 +
   1.286 +            auto_type old( where->second );       // nothrow
   1.287 +            where.base()->second = ptr.release(); // nothrow, commit
   1.288 +            return move( old );
   1.289 +        }
   1.290 +
   1.291 +        template< class U >
   1.292 +        auto_type replace( iterator where, std::auto_ptr<U> x )
   1.293 +        {
   1.294 +            return replace( where, x.release() );
   1.295 +        }
   1.296 +
   1.297 +    public: // serialization
   1.298 +
   1.299 +        template< class Archive >
   1.300 +        void save( Archive& ar, const unsigned ) const
   1.301 +        {
   1.302 +            ar & ptr_container_detail::serialize_as_const( this->size() );
   1.303 +
   1.304 +            const_iterator i = this->begin(), e = this->end();
   1.305 +            for( ; i != e; ++i )
   1.306 +            {
   1.307 +                ar & i->first;
   1.308 +                ar & ptr_container_detail::serialize_as_const( i->second );
   1.309 +            }
   1.310 +        }
   1.311 +    };
   1.312 +    
   1.313 +} // ptr_container_detail
   1.314 +
   1.315 +    /////////////////////////////////////////////////////////////////////////
   1.316 +    // ptr_map_adapter
   1.317 +    /////////////////////////////////////////////////////////////////////////
   1.318 +    
   1.319 +    template
   1.320 +    < 
   1.321 +        class T,
   1.322 +        class VoidPtrMap, 
   1.323 +        class CloneAllocator = heap_clone_allocator
   1.324 +    >
   1.325 +    class ptr_map_adapter : 
   1.326 +        public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator>
   1.327 +    {
   1.328 +        typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator> 
   1.329 +            base_type;
   1.330 +    
   1.331 +    public:    
   1.332 +        typedef BOOST_DEDUCED_TYPENAME base_type::iterator 
   1.333 +                     iterator;       
   1.334 +        typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
   1.335 +                     const_iterator;
   1.336 +        typedef BOOST_DEDUCED_TYPENAME base_type::size_type
   1.337 +                    size_type;
   1.338 +        typedef BOOST_DEDUCED_TYPENAME base_type::key_type
   1.339 +                    key_type;
   1.340 +        typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
   1.341 +                    const_reference;
   1.342 +        typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
   1.343 +                    auto_type;
   1.344 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::key_compare 
   1.345 +                    key_compare;
   1.346 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type 
   1.347 +                    allocator_type;
   1.348 +        typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
   1.349 +                    mapped_type;
   1.350 +    private:
   1.351 +
   1.352 +        void safe_insert( const key_type& key, auto_type ptr ) // strong
   1.353 +        {
   1.354 +            std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
   1.355 +                res = 
   1.356 +                this->c_private().insert( std::make_pair( key, ptr.get() ) ); // strong, commit      
   1.357 +            if( res.second )                                                  // nothrow     
   1.358 +                ptr.release();                                                // nothrow
   1.359 +        }
   1.360 +    
   1.361 +        template< class II >                                               
   1.362 +        void map_basic_clone_and_insert( II first, II last )                  
   1.363 +        {       
   1.364 +            while( first != last )                                            
   1.365 +            {                                            
   1.366 +                if( this->find( first->first ) == this->end() )
   1.367 +                {
   1.368 +                    const_reference p = *first.base();     // nothrow                    
   1.369 +                    auto_type ptr( this->null_policy_allocate_clone( p.second ) ); 
   1.370 +                                                              // strong 
   1.371 +                    this->safe_insert( p.first, ptr_container_detail::
   1.372 +                                                move( ptr ) );// strong, commit
   1.373 +                }
   1.374 +                ++first;                                                      
   1.375 +            }                                                                 
   1.376 +        }
   1.377 +    
   1.378 +    public:
   1.379 +
   1.380 +        explicit ptr_map_adapter( const key_compare& comp = key_compare(),
   1.381 +                                  const allocator_type& a = allocator_type()  ) 
   1.382 +          : base_type( comp, a ) { }
   1.383 +    
   1.384 +        template< class InputIterator >
   1.385 +        ptr_map_adapter( InputIterator first, InputIterator last, 
   1.386 +                         const key_compare& comp = key_compare(),
   1.387 +                         const allocator_type& a = allocator_type() )
   1.388 +          : base_type( comp, a ) 
   1.389 +        {
   1.390 +            map_basic_clone_and_insert( first, last );
   1.391 +        }
   1.392 +
   1.393 +        template< class U >
   1.394 +        ptr_map_adapter( std::auto_ptr<U> r ) : base_type( r )
   1.395 +        { }
   1.396 +
   1.397 +        template< class U >
   1.398 +        void operator=( std::auto_ptr<U> r )
   1.399 +        {  
   1.400 +            base_type::operator=( r );
   1.401 +        }
   1.402 +
   1.403 +        using base_type::release;
   1.404 +
   1.405 +        template< typename InputIterator >
   1.406 +        void insert( InputIterator first, InputIterator last ) // basic
   1.407 +        {
   1.408 +            map_basic_clone_and_insert( first, last );
   1.409 +        }
   1.410 +
   1.411 +        template< class Range >
   1.412 +        void insert( const Range& r )
   1.413 +        {
   1.414 +            insert( boost::begin(r), boost::end(r) );
   1.415 +        }
   1.416 +
   1.417 +    private:
   1.418 +        std::pair<iterator,bool> insert_impl( const key_type& key, mapped_type x ) // strong
   1.419 +        {
   1.420 +            this->enforce_null_policy( x, "Null pointer in ptr_map_adapter::insert()" );
   1.421 +            auto_type ptr( x );                                              // nothrow
   1.422 +
   1.423 +            std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
   1.424 +                 res = this->c_private().insert( std::make_pair( key, x ) ); // strong, commit      
   1.425 +            if( res.second )                                             // nothrow     
   1.426 +                ptr.release();                                           // nothrow
   1.427 +            return std::make_pair( iterator( res.first ), res.second );  // nothrow        
   1.428 +        }
   1.429 +        
   1.430 +    public:
   1.431 +        
   1.432 +        std::pair<iterator,bool> insert( key_type& key, mapped_type x )
   1.433 +        {
   1.434 +            return insert_impl( key, x );
   1.435 +        }
   1.436 +
   1.437 +        template< class U >
   1.438 +        std::pair<iterator,bool> insert( const key_type& key, std::auto_ptr<U> x )
   1.439 +        {
   1.440 +            return insert_impl( key, x.release() );
   1.441 +        }
   1.442 +
   1.443 +        template< class PtrMapAdapter >
   1.444 +        bool transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object, 
   1.445 +                       PtrMapAdapter& from ) // strong
   1.446 +        {
   1.447 +            return this->single_transfer( object, from );
   1.448 +        }
   1.449 +
   1.450 +        template< class PtrMapAdapter >
   1.451 +        size_type transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator first, 
   1.452 +                            BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator last, 
   1.453 +                            PtrMapAdapter& from ) // basic
   1.454 +        {
   1.455 +            return this->single_transfer( first, last, from );
   1.456 +        }
   1.457 +
   1.458 +#if defined(BOOST_NO_SFINAE) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)
   1.459 +#else    
   1.460 +
   1.461 +        template< class PtrMapAdapter, class Range >
   1.462 +        BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
   1.463 +                            BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator >,
   1.464 +                                                            size_type >::type
   1.465 +        transfer( const Range& r, PtrMapAdapter& from ) // basic
   1.466 +        {
   1.467 +            return transfer( boost::begin(r), boost::end(r), from );
   1.468 +        }
   1.469 +        
   1.470 +#endif
   1.471 +
   1.472 +        template< class PtrMapAdapter >
   1.473 +        size_type transfer( PtrMapAdapter& from ) // basic
   1.474 +        {
   1.475 +            return transfer( from.begin(), from.end(), from );
   1.476 +        }
   1.477 +
   1.478 +    public: // serialization
   1.479 +
   1.480 +        template< class Archive >
   1.481 +        void load( Archive& ar, const unsigned ) // strong
   1.482 +        {
   1.483 +            this->clear();
   1.484 +            size_type n;
   1.485 +            ar & n;
   1.486 +
   1.487 +            for( size_type i = 0u; i != n; ++i )
   1.488 +            {
   1.489 +                key_type  key;
   1.490 +                T*        value;
   1.491 +                ar & key;
   1.492 +                ar & value;
   1.493 +                std::pair<iterator,bool> p = this->insert( key, value );
   1.494 +                ar.reset_object_address( &p.first->first, &key ); 
   1.495 +            }
   1.496 +        }
   1.497 +
   1.498 +        BOOST_SERIALIZATION_SPLIT_MEMBER()
   1.499 +        
   1.500 +  };
   1.501 +  
   1.502 +  /////////////////////////////////////////////////////////////////////////
   1.503 +  // ptr_multimap_adapter
   1.504 +  /////////////////////////////////////////////////////////////////////////
   1.505 +
   1.506 +    template
   1.507 +    < 
   1.508 +        class T,
   1.509 +        class VoidPtrMultiMap, 
   1.510 +        class CloneAllocator = heap_clone_allocator
   1.511 +    >
   1.512 +    class ptr_multimap_adapter : 
   1.513 +        public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator>
   1.514 +    {
   1.515 +        typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator>
   1.516 +             base_type;
   1.517 +
   1.518 +    public: // typedefs
   1.519 +        typedef BOOST_DEDUCED_TYPENAME base_type::iterator           
   1.520 +                       iterator;                 
   1.521 +        typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator     
   1.522 +                       const_iterator;           
   1.523 +        typedef BOOST_DEDUCED_TYPENAME base_type::size_type
   1.524 +                       size_type;
   1.525 +        typedef BOOST_DEDUCED_TYPENAME base_type::key_type
   1.526 +                       key_type;
   1.527 +        typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
   1.528 +                       const_reference;
   1.529 +        typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
   1.530 +                    mapped_type;
   1.531 +        typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
   1.532 +                    auto_type;            
   1.533 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiMap::key_compare 
   1.534 +                    key_compare;
   1.535 +        typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiMap::allocator_type 
   1.536 +                    allocator_type;
   1.537 +    private:
   1.538 +
   1.539 +        void safe_insert( const key_type& key, auto_type ptr ) // strong
   1.540 +        {
   1.541 +            this->c_private().insert( 
   1.542 +                           std::make_pair( key, ptr.get() ) ); // strong, commit      
   1.543 +            ptr.release();                                     // nothrow
   1.544 +        }
   1.545 +        
   1.546 +        template< typename II >                                               
   1.547 +        void map_basic_clone_and_insert( II first, II last )                  
   1.548 +        {                                                         
   1.549 +            while( first != last )                                            
   1.550 +            {                                            
   1.551 +                const_reference pair = *first.base();     // nothrow                     
   1.552 +                auto_type ptr( this->null_policy_allocate_clone( pair.second ) );    
   1.553 +                                                          // strong
   1.554 +                safe_insert( pair.first, ptr_container_detail::
   1.555 +                                         move( ptr ) );   // strong, commit
   1.556 +                ++first;                                                      
   1.557 +            }                                                                 
   1.558 +        }
   1.559 +        
   1.560 +    public:
   1.561 +        
   1.562 +        explicit ptr_multimap_adapter( const key_compare& comp = key_compare(),
   1.563 +                                       const allocator_type& a = allocator_type() )
   1.564 +          : base_type( comp, a ) { }
   1.565 +        
   1.566 +        template< class InputIterator >
   1.567 +        ptr_multimap_adapter( InputIterator first, InputIterator last,
   1.568 +                              const key_compare& comp = key_compare(),
   1.569 +                              const allocator_type& a = allocator_type() )
   1.570 +          : base_type( comp, a )
   1.571 +        {
   1.572 +            map_basic_clone_and_insert( first, last );
   1.573 +        }
   1.574 +
   1.575 +        template< class U >
   1.576 +        ptr_multimap_adapter( std::auto_ptr<U> r ) : base_type( r )
   1.577 +        { }
   1.578 +
   1.579 +        template< class U >
   1.580 +        void operator=( std::auto_ptr<U> r )
   1.581 +        {  
   1.582 +            base_type::operator=( r );
   1.583 +        }
   1.584 +
   1.585 +        using base_type::release;
   1.586 +        
   1.587 +        template< typename InputIterator >
   1.588 +        void insert( InputIterator first, InputIterator last ) // basic
   1.589 +        {
   1.590 +            map_basic_clone_and_insert( first, last );
   1.591 +        }
   1.592 +
   1.593 +        template< class Range >
   1.594 +        void insert( const Range& r )
   1.595 +        {
   1.596 +            insert( boost::begin(r), boost::end(r) );
   1.597 +        }
   1.598 +
   1.599 +        iterator insert( key_type& key, mapped_type x ) // strong
   1.600 +        {
   1.601 +            this->enforce_null_policy( x, 
   1.602 +                  "Null pointer in 'ptr_multimap_adapter::insert()'" );
   1.603 +
   1.604 +            auto_type ptr( x );         // nothrow
   1.605 +            BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
   1.606 +                res = this->c_private().insert( std::make_pair( key, x ) );
   1.607 +                                        // strong, commit        
   1.608 +            ptr.release();              // notrow
   1.609 +            return iterator( res );           
   1.610 +        }
   1.611 +
   1.612 +        template< class U >
   1.613 +        iterator insert( key_type& key, std::auto_ptr<U> x )
   1.614 +        {
   1.615 +            return insert( key, x.release() );
   1.616 +        }
   1.617 +
   1.618 +        template< class PtrMapAdapter >
   1.619 +        void transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object, 
   1.620 +                       PtrMapAdapter& from ) // strong
   1.621 +        {
   1.622 +            this->multi_transfer( object, from );
   1.623 +        }
   1.624 +
   1.625 +        template< class PtrMapAdapter >
   1.626 +        size_type transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator first, 
   1.627 +                            BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator last, 
   1.628 +                            PtrMapAdapter& from ) // basic
   1.629 +        {
   1.630 +            return this->multi_transfer( first, last, from );
   1.631 +        }
   1.632 +
   1.633 +#if defined(BOOST_NO_SFINAE) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)        
   1.634 +#else    
   1.635 +
   1.636 +        template<  class PtrMapAdapter, class Range >
   1.637 +        BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
   1.638 +                            BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator >,
   1.639 +                                                            size_type >::type
   1.640 +        transfer( const Range& r, PtrMapAdapter& from ) // basic
   1.641 +        {
   1.642 +            return transfer( boost::begin(r), boost::end(r), from );
   1.643 +        }
   1.644 +
   1.645 +#endif        
   1.646 +        template< class PtrMapAdapter >
   1.647 +        void transfer( PtrMapAdapter& from ) // basic
   1.648 +        {
   1.649 +            transfer( from.begin(), from.end(), from );
   1.650 +            BOOST_ASSERT( from.empty() );
   1.651 +        }
   1.652 +
   1.653 +    public: // serialization
   1.654 +
   1.655 +        template< class Archive >
   1.656 +        void load( Archive& ar, const unsigned ) // basic
   1.657 +        {
   1.658 +            this->clear();
   1.659 +            size_type n;
   1.660 +            ar & n;
   1.661 +
   1.662 +            for( size_type i = 0u; i != n; ++i )
   1.663 +            {
   1.664 +                key_type  key;
   1.665 +                T*        value;
   1.666 +                ar & key;
   1.667 +                ar & value;
   1.668 +                iterator p = this->insert( key, value );
   1.669 +                ar.reset_object_address( &p->first, &key );
   1.670 +            }
   1.671 +        }
   1.672 +
   1.673 +        BOOST_SERIALIZATION_SPLIT_MEMBER()
   1.674 +
   1.675 +    };
   1.676 +
   1.677 +    template< class I, class F, class S >
   1.678 +    inline bool is_null( const ptr_map_iterator<I,F,S>& i )
   1.679 +    {
   1.680 +        return i->second == 0;
   1.681 +    }
   1.682 +    
   1.683 +} // namespace 'boost'  
   1.684 +
   1.685 +#endif