diff options
Diffstat (limited to 'boost/ptr_container')
25 files changed, 335 insertions, 259 deletions
diff --git a/boost/ptr_container/clone_allocator.hpp b/boost/ptr_container/clone_allocator.hpp index 6d396e808a..cca885c74c 100644 --- a/boost/ptr_container/clone_allocator.hpp +++ b/boost/ptr_container/clone_allocator.hpp @@ -37,18 +37,7 @@ namespace boost return res; } - template< class T > - inline T* new_clone( const T* r ) - { - return r ? new_clone( *r ) : 0; - } - // - // @remark: to make new_clone() work - // with scope_ptr/shared_ptr ect. - // simply overload for those types - // in the appropriate namespace. - // template< class T > inline void delete_clone( const T* r ) diff --git a/boost/ptr_container/detail/default_deleter.hpp b/boost/ptr_container/detail/default_deleter.hpp index 44647990cb..86914b29d7 100755..100644 --- a/boost/ptr_container/detail/default_deleter.hpp +++ b/boost/ptr_container/detail/default_deleter.hpp @@ -61,7 +61,7 @@ struct default_deleter { default_deleter() { } template<typename TT> - default_deleter(default_deleter<TT> tt) { } + default_deleter(default_deleter<TT>) { } }; } } } // End namespaces ptr_container_detail, move_ptrs, boost. diff --git a/boost/ptr_container/detail/is_convertible.hpp b/boost/ptr_container/detail/is_convertible.hpp index fd17781925..fd17781925 100755..100644 --- a/boost/ptr_container/detail/is_convertible.hpp +++ b/boost/ptr_container/detail/is_convertible.hpp diff --git a/boost/ptr_container/detail/map_iterator.hpp b/boost/ptr_container/detail/map_iterator.hpp index e3ff4f2b49..518ba217d9 100644 --- a/boost/ptr_container/detail/map_iterator.hpp +++ b/boost/ptr_container/detail/map_iterator.hpp @@ -48,8 +48,8 @@ namespace boost ref_pair( const RP* rp ) : first(rp->first), second(rp->second) { } - - const ref_pair* const operator->() const + + const ref_pair* operator->() const { return this; } diff --git a/boost/ptr_container/detail/move.hpp b/boost/ptr_container/detail/move.hpp index bf07d5f563..bf07d5f563 100755..100644 --- a/boost/ptr_container/detail/move.hpp +++ b/boost/ptr_container/detail/move.hpp diff --git a/boost/ptr_container/detail/reversible_ptr_container.hpp b/boost/ptr_container/detail/reversible_ptr_container.hpp index 47c3903f46..930f468b6b 100644 --- a/boost/ptr_container/detail/reversible_ptr_container.hpp +++ b/boost/ptr_container/detail/reversible_ptr_container.hpp @@ -35,12 +35,14 @@ #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_pointer.hpp> #include <boost/type_traits/is_integral.hpp> +#include <boost/swap.hpp> #include <typeinfo> #include <memory> #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) #pragma warning(push) #pragma warning(disable:4127) +#pragma warning(disable:4224) // formal parameter was previously defined as a type. #endif namespace boost @@ -48,12 +50,32 @@ namespace boost namespace ptr_container_detail { + template< class Container > + struct dynamic_clone_deleter + { + dynamic_clone_deleter() { } + dynamic_clone_deleter( Container& cont ) : cont(&cont) { } + Container* cont; + + template< class T > + void operator()( const T* p ) const + { + // remark: static_move_ptr already test for null + cont->get_clone_allocator().deallocate_clone( p ); + } + }; + template< class CloneAllocator > - struct clone_deleter + struct static_clone_deleter { + static_clone_deleter() { } + template< class Dummy > + static_clone_deleter( const Dummy& ) { } + template< class T > void operator()( const T* p ) const { + // remark: static_move_ptr already test for null CloneAllocator::deallocate_clone( p ); } }; @@ -79,71 +101,26 @@ namespace ptr_container_detail class Config, class CloneAllocator > - class reversible_ptr_container + class reversible_ptr_container : CloneAllocator { private: BOOST_STATIC_CONSTANT( bool, allow_null = Config::allow_null ); - - typedef BOOST_DEDUCED_TYPENAME Config::value_type Ty_; - - template< bool allow_null_values > - struct null_clone_allocator - { - template< class Iter > - static Ty_* allocate_clone_from_iterator( Iter i ) - { - return allocate_clone( Config::get_const_pointer( i ) ); - } - - static Ty_* allocate_clone( const Ty_* x ) - { - if( allow_null_values ) - { - if( x == 0 ) - return 0; - } - else - { - BOOST_ASSERT( x != 0 && "Cannot insert clone of null!" ); - } - - Ty_* res = CloneAllocator::allocate_clone( *x ); - BOOST_ASSERT( typeid(*res) == typeid(*x) && - "CloneAllocator::allocate_clone() does not clone the " - "object properly. Check that new_clone() is implemented" - " correctly" ); - return res; - } - - static void deallocate_clone( const Ty_* x ) - { - if( allow_null_values ) - { - if( x == 0 ) - return; - } + BOOST_STATIC_CONSTANT( bool, is_clone_allocator_empty = sizeof(CloneAllocator) < sizeof(void*) ); - CloneAllocator::deallocate_clone( x ); - } - }; - - typedef BOOST_DEDUCED_TYPENAME Config::void_container_type Cont; -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - typedef null_clone_allocator<reversible_ptr_container::allow_null> - null_cloner_type; -#else - typedef null_clone_allocator<allow_null> null_cloner_type; -#endif - typedef clone_deleter<null_cloner_type> Deleter; - - Cont c_; + typedef BOOST_DEDUCED_TYPENAME Config::value_type Ty_; + typedef BOOST_DEDUCED_TYPENAME Config::void_container_type container_type; + typedef dynamic_clone_deleter<reversible_ptr_container> dynamic_deleter_type; + typedef static_clone_deleter<CloneAllocator> static_deleter_type; + + container_type c_; public: - Cont& base() { return c_; } + container_type& base() { return c_; } protected: // having this public could break encapsulation - const Cont& base() const { return c_; } + const container_type& base() const { return c_; } public: // typedefs + typedef Ty_ object_type; typedef Ty_* value_type; typedef Ty_* pointer; typedef Ty_& reference; @@ -157,23 +134,27 @@ namespace ptr_container_detail reverse_iterator; typedef boost::reverse_iterator< const_iterator > const_reverse_iterator; - typedef BOOST_DEDUCED_TYPENAME Cont::difference_type + typedef BOOST_DEDUCED_TYPENAME container_type::difference_type difference_type; - typedef BOOST_DEDUCED_TYPENAME Cont::size_type + typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type; typedef BOOST_DEDUCED_TYPENAME Config::allocator_type allocator_type; typedef CloneAllocator clone_allocator_type; - typedef ptr_container_detail::static_move_ptr<Ty_,Deleter> + typedef ptr_container_detail::static_move_ptr<Ty_, + BOOST_DEDUCED_TYPENAME boost::mpl::if_c<is_clone_allocator_empty, + static_deleter_type, + dynamic_deleter_type>::type + > auto_type; protected: - typedef ptr_container_detail::scoped_deleter<Ty_,null_cloner_type> + typedef ptr_container_detail::scoped_deleter<reversible_ptr_container> scoped_deleter; - typedef BOOST_DEDUCED_TYPENAME Cont::iterator + typedef BOOST_DEDUCED_TYPENAME container_type::iterator ptr_iterator; - typedef BOOST_DEDUCED_TYPENAME Cont::const_iterator + typedef BOOST_DEDUCED_TYPENAME container_type::const_iterator ptr_const_iterator; private: @@ -185,7 +166,7 @@ namespace ptr_container_detail void copy( const reversible_ptr_container& r ) { - copy( r.begin(), r.end() ); + this->copy( r.begin(), r.end() ); } void copy_clones_and_release( scoped_deleter& sd ) // nothrow @@ -200,8 +181,8 @@ namespace ptr_container_detail ForwardIterator last ) // strong { BOOST_ASSERT( first != last ); - scoped_deleter sd( first, last ); // strong - copy_clones_and_release( sd ); // nothrow + scoped_deleter sd( *this, first, last ); // strong + copy_clones_and_release( sd ); // nothrow } template< class ForwardIterator > @@ -209,13 +190,13 @@ namespace ptr_container_detail ForwardIterator last ) { BOOST_ASSERT( first != last ); - scoped_deleter sd( first, last ); + scoped_deleter sd( *this, first, last ); insert_clones_and_release( sd, end() ); } void remove_all() { - remove( begin(), end() ); + this->remove( begin(), end() ); } protected: @@ -241,20 +222,20 @@ namespace ptr_container_detail template< class U > void remove( U* ptr ) { - null_policy_deallocate_clone( ptr ); + this->deallocate_clone( ptr ); } template< class I > void remove( I i ) { - null_policy_deallocate_clone( Config::get_const_pointer(i) ); + this->deallocate_clone( Config::get_const_pointer(i) ); } template< class I > void remove( I first, I last ) { for( ; first != last; ++first ) - remove( first ); + this->remove( first ); } static void enforce_null_policy( const Ty_* x, const char* msg ) @@ -266,16 +247,44 @@ namespace ptr_container_detail } } - static Ty_* null_policy_allocate_clone( const Ty_* x ) + public: + Ty_* null_policy_allocate_clone( const Ty_* x ) { - return null_cloner_type::allocate_clone( x ); + if( allow_null ) + { + if( x == 0 ) + return 0; + } + else + { + BOOST_ASSERT( x != 0 && "Cannot insert clone of null!" ); + } + + Ty_* res = this->get_clone_allocator().allocate_clone( *x ); + BOOST_ASSERT( typeid(*res) == typeid(*x) && + "CloneAllocator::allocate_clone() does not clone the " + "object properly. Check that new_clone() is implemented" + " correctly" ); + return res; } - static void null_policy_deallocate_clone( const Ty_* x ) + template< class Iterator > + Ty_* null_policy_allocate_clone_from_iterator( Iterator i ) { - null_cloner_type::deallocate_clone( x ); + return this->null_policy_allocate_clone(Config::get_const_pointer(i)); } + + void null_policy_deallocate_clone( const Ty_* x ) + { + if( allow_null ) + { + if( x == 0 ) + return; + } + this->get_clone_allocator().deallocate_clone( x ); + } + private: template< class ForwardIterator > ForwardIterator advance( ForwardIterator begin, size_type n ) @@ -290,7 +299,7 @@ namespace ptr_container_detail { while( first != last ) { - insert( end(), null_cloner_type::allocate_clone_from_iterator(first) ); + insert( end(), this->allocate_clone_from_iterator(first) ); ++first; } } @@ -309,11 +318,11 @@ namespace ptr_container_detail if( first == last ) return; - scoped_deleter sd( first, last ); + scoped_deleter sd( *this, first, last ); insert_clones_and_release( sd ); } - public: // foundation! should be protected! + public: // foundation: should be protected, but public for poor compilers' sake. reversible_ptr_container() { } @@ -471,6 +480,16 @@ namespace ptr_container_detail { return c_.get_allocator(); } + + clone_allocator_type& get_clone_allocator() + { + return static_cast<clone_allocator_type&>(*this); + } + + const clone_allocator_type& get_clone_allocator() const + { + return static_cast<const clone_allocator_type&>(*this); + } public: // container requirements iterator begin() @@ -503,7 +522,8 @@ namespace ptr_container_detail void swap( reversible_ptr_container& r ) // nothrow { - c_.swap( r.c_ ); + boost::swap( get_clone_allocator(), r.get_clone_allocator() ); // nothrow + c_.swap( r.c_ ); // nothrow } size_type size() const // nothrow @@ -562,7 +582,7 @@ namespace ptr_container_detail { enforce_null_policy( x, "Null pointer in 'insert()'" ); - auto_type ptr( x ); // nothrow + auto_type ptr( x, *this ); // nothrow iterator res( c_.insert( before.base(), x ) ); // strong, commit ptr.release(); // nothrow return res; @@ -611,23 +631,21 @@ namespace ptr_container_detail BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation, "'release()' on empty container" ); - auto_type ptr( Config::get_pointer( where ) ); // nothrow - c_.erase( where.base() ); // nothrow + auto_type ptr( Config::get_pointer(where), *this ); // nothrow + c_.erase( where.base() ); // nothrow return boost::ptr_container_detail::move( ptr ); } auto_type replace( iterator where, Ty_* x ) // strong { BOOST_ASSERT( where != end() ); + enforce_null_policy( x, "Null pointer in 'replace()'" ); - enforce_null_policy( x, "Null pointer in 'replace()'" ); - - auto_type ptr( x ); - + auto_type ptr( x, *this ); BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation, "'replace()' on empty container" ); - auto_type old( Config::get_pointer( where ) ); // nothrow + auto_type old( Config::get_pointer(where), *this ); // nothrow const_cast<void*&>(*where.base()) = ptr.release(); return boost::ptr_container_detail::move( old ); } @@ -640,15 +658,14 @@ namespace ptr_container_detail auto_type replace( size_type idx, Ty_* x ) // strong { - enforce_null_policy( x, "Null pointer in 'replace()'" ); - - auto_type ptr( x ); - + enforce_null_policy( x, "Null pointer in 'replace()'" ); + + auto_type ptr( x, *this ); BOOST_PTR_CONTAINER_THROW_EXCEPTION( idx >= size(), bad_index, "'replace()' out of bounds" ); - auto_type old( static_cast<Ty_*>( c_[idx] ) ); // nothrow - c_[idx] = ptr.release(); // nothrow, commit + auto_type old( static_cast<Ty_*>(c_[idx]), *this ); // nothrow + c_[idx] = ptr.release(); // nothrow, commit return boost::ptr_container_detail::move( old ); } diff --git a/boost/ptr_container/detail/scoped_deleter.hpp b/boost/ptr_container/detail/scoped_deleter.hpp index a2e7aba2ea..38bbea932e 100755..100644 --- a/boost/ptr_container/detail/scoped_deleter.hpp +++ b/boost/ptr_container/detail/scoped_deleter.hpp @@ -25,49 +25,60 @@ namespace boost namespace ptr_container_detail { - template< class T, class CloneAllocator > + template< class Container > class scoped_deleter { - typedef std::size_t size_type; + typedef BOOST_DEDUCED_TYPENAME Container::size_type size_type; + typedef BOOST_DEDUCED_TYPENAME Container::object_type T; + + Container& cont_; scoped_array<T*> ptrs_; size_type stored_; bool released_; public: - scoped_deleter( T** a, size_type size ) - : ptrs_( a ), stored_( size ), released_( false ) + scoped_deleter( Container& cont, T** a, size_type size ) + : cont_(cont), + ptrs_( a ), + stored_( size ), + released_( false ) { BOOST_ASSERT( a ); } - scoped_deleter( size_type size ) - : ptrs_( new T*[size] ), stored_( 0 ), - released_( false ) + scoped_deleter( Container& cont, size_type size ) + : cont_(cont), + ptrs_( new T*[size] ), + stored_( 0 ), + released_( false ) { BOOST_ASSERT( size > 0 ); } - scoped_deleter( size_type n, const T& x ) // strong - : ptrs_( new T*[n] ), stored_(0), + scoped_deleter( Container& cont, size_type n, const T& x ) // strong + : cont_(cont), + ptrs_( new T*[n] ), + stored_(0), released_( false ) { for( size_type i = 0; i != n; i++ ) - add( CloneAllocator::allocate_clone( &x ) ); + add( cont_.null_policy_allocate_clone( &x ) ); BOOST_ASSERT( stored_ > 0 ); } template< class InputIterator > - scoped_deleter ( InputIterator first, InputIterator last ) // strong - : ptrs_( new T*[ std::distance(first,last) ] ), + scoped_deleter ( Container& cont, InputIterator first, InputIterator last ) // strong + : cont_(cont), + ptrs_( new T*[ std::distance(first,last) ] ), stored_(0), released_( false ) { for( ; first != last; ++first ) - add( CloneAllocator::allocate_clone_from_iterator( first ) ); + add( cont_.null_policy_allocate_clone_from_iterator( first ) ); BOOST_ASSERT( stored_ > 0 ); } @@ -78,7 +89,7 @@ namespace boost if ( !released_ ) { for( size_type i = 0u; i != stored_; ++i ) - CloneAllocator::deallocate_clone( ptrs_[i] ); + cont_.null_policy_deallocate_clone( ptrs_[i] ); } } diff --git a/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp b/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp index a85bf4c8bc..d0e93dfdcb 100644 --- a/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp +++ b/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp @@ -9,7 +9,7 @@ #include <boost/ptr_container/ptr_map_adapter.hpp> #include <boost/ptr_container/detail/serialize_xml_names.hpp> #include <boost/serialization/split_free.hpp> -#include <boost/serialization/nvp.hpp> +#include <boost/serialization/nvp.hpp> namespace boost { diff --git a/boost/ptr_container/detail/static_move_ptr.hpp b/boost/ptr_container/detail/static_move_ptr.hpp index 6af3461a36..1f096c765d 100644 --- a/boost/ptr_container/detail/static_move_ptr.hpp +++ b/boost/ptr_container/detail/static_move_ptr.hpp @@ -76,8 +76,8 @@ public: } template<typename TT> - explicit static_move_ptr(TT* tt) - : impl_(tt, Deleter()) + static_move_ptr(TT* tt, Deleter del) + : impl_(tt, del) { } // Destructor @@ -131,13 +131,7 @@ public: } template<typename TT> - void reset(TT* tt) - { - static_move_ptr(tt).swap(*this); - } - - template<typename TT, typename DD> - void reset(TT* tt, DD dd) + void reset(TT* tt, Deleter dd) { static_move_ptr(tt, dd).swap(*this); } @@ -151,7 +145,7 @@ public: deleter_const_reference get_deleter() const { return impl_.second(); } private: template<typename TT, typename DD> - void check(const static_move_ptr<TT, DD>& ptr) + void check(const static_move_ptr<TT, DD>&) { typedef move_ptrs::is_smart_ptr_convertible<TT, T> convertible; BOOST_STATIC_ASSERT(convertible::value); diff --git a/boost/ptr_container/detail/throw_exception.hpp b/boost/ptr_container/detail/throw_exception.hpp index bb467f2bd9..bb467f2bd9 100755..100644 --- a/boost/ptr_container/detail/throw_exception.hpp +++ b/boost/ptr_container/detail/throw_exception.hpp diff --git a/boost/ptr_container/detail/void_ptr_iterator.hpp b/boost/ptr_container/detail/void_ptr_iterator.hpp index 937ffb4aa2..5a96eb4719 100755..100644 --- a/boost/ptr_container/detail/void_ptr_iterator.hpp +++ b/boost/ptr_container/detail/void_ptr_iterator.hpp @@ -161,8 +161,22 @@ namespace boost return r; } + + namespace ptr_container_detail + { + template<typename T, typename U> + struct is_compatible + { + static const bool value = boost::is_same< typename boost::remove_const<T>::type, typename boost::remove_const<U>::type >::value; + }; + } + + template< class VoidIter, class T, class VoidIterU, class U > - inline BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type + >::type operator-( void_ptr_iterator<VoidIter,T> l, void_ptr_iterator<VoidIterU,U> r ) @@ -173,7 +187,11 @@ namespace boost template< class VoidIterT, class T, class VoidIterU, class U > - inline bool operator==( const void_ptr_iterator<VoidIterT,T>& l, + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + bool + >::type + operator==( const void_ptr_iterator<VoidIterT,T>& l, const void_ptr_iterator<VoidIterU,U>& r ) { return l.base() == r.base(); @@ -182,7 +200,11 @@ namespace boost template< class VoidIterT, class T, class VoidIterU, class U > - inline bool operator!=( const void_ptr_iterator<VoidIterT,T>& l, + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + bool + >::type + operator!=( const void_ptr_iterator<VoidIterT,T>& l, const void_ptr_iterator<VoidIterU,U>& r ) { return l.base() != r.base(); @@ -191,7 +213,11 @@ namespace boost template< class VoidIterT, class T, class VoidIterU, class U > - inline bool operator<( const void_ptr_iterator<VoidIterT,T>& l, + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + bool + >::type + operator<( const void_ptr_iterator<VoidIterT,T>& l, const void_ptr_iterator<VoidIterU,U>& r ) { return l.base() < r.base(); @@ -200,7 +226,11 @@ namespace boost template< class VoidIterT, class T, class VoidIterU, class U > - inline bool operator<=( const void_ptr_iterator<VoidIterT,T>& l, + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + bool + >::type + operator<=( const void_ptr_iterator<VoidIterT,T>& l, const void_ptr_iterator<VoidIterU,U>& r ) { return l.base() <= r.base(); @@ -209,7 +239,11 @@ namespace boost template< class VoidIterT, class T, class VoidIterU, class U > - inline bool operator>( const void_ptr_iterator<VoidIterT,T>& l, + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + bool + >::type + operator>( const void_ptr_iterator<VoidIterT,T>& l, const void_ptr_iterator<VoidIterU,U>& r ) { return l.base() > r.base(); @@ -218,7 +252,11 @@ namespace boost template< class VoidIterT, class T, class VoidIterU, class U > - inline bool operator>=( const void_ptr_iterator<VoidIterT,T>& l, + inline BOOST_DEDUCED_TYPENAME boost::enable_if< + ptr_container_detail::is_compatible<T, U>, + bool + >::type + operator>=( const void_ptr_iterator<VoidIterT,T>& l, const void_ptr_iterator<VoidIterU,U>& r ) { return l.base() >= r.base(); diff --git a/boost/ptr_container/nullable.hpp b/boost/ptr_container/nullable.hpp index b3e4603d1e..5934812f48 100755..100644 --- a/boost/ptr_container/nullable.hpp +++ b/boost/ptr_container/nullable.hpp @@ -18,6 +18,7 @@ #endif #include <boost/type_traits/detail/yes_no_type.hpp> +#include <boost/type_traits/is_const.hpp> #include <boost/mpl/eval_if.hpp> #include <boost/mpl/identity.hpp> #include <boost/config.hpp> @@ -68,6 +69,17 @@ namespace boost type; }; + namespace ptr_container_detail + { + template< class T > + struct void_ptr + { + typedef BOOST_DEDUCED_TYPENAME + mpl::if_c< boost::is_const< + BOOST_DEDUCED_TYPENAME boost::remove_nullable<T>::type >::value, + const void*, void* >::type type; + }; + } } #endif diff --git a/boost/ptr_container/ptr_array.hpp b/boost/ptr_container/ptr_array.hpp index 9ab6473e3d..6bddb73375 100644 --- a/boost/ptr_container/ptr_array.hpp +++ b/boost/ptr_container/ptr_array.hpp @@ -56,12 +56,14 @@ namespace boost > class ptr_array : public ptr_sequence_adapter< T, - ptr_container_detail::ptr_array_impl<void*,N>, + ptr_container_detail::ptr_array_impl< + typename ptr_container_detail::void_ptr<T>::type,N>, CloneAllocator > { private: typedef ptr_sequence_adapter< T, - ptr_container_detail::ptr_array_impl<void*,N>, + ptr_container_detail::ptr_array_impl< + typename ptr_container_detail::void_ptr<T>::type,N>, CloneAllocator > base_class; @@ -88,7 +90,7 @@ namespace boost size_t i = 0; for( ; i != N; ++i ) this->base()[i] = this->null_policy_allocate_clone( - static_cast<const T*>( &r[i] ) ); + static_cast<const U*>( &r[i] ) ); } template< class U > @@ -127,8 +129,8 @@ namespace boost std::auto_ptr<this_type> pa( new this_type ); for( size_t i = 0; i != N; ++i ) { - if( ! is_null(i) ) - pa->replace( i, this->null_policy_allocate_clone( &(*this)[i] ) ); + if( !this->is_null(i) ) + pa->replace( i, pa->null_policy_allocate_clone( &(*this)[i] ) ); } return pa; } @@ -151,10 +153,9 @@ namespace boost BOOST_STATIC_ASSERT( idx < N ); this->enforce_null_policy( r, "Null pointer in 'ptr_array::replace()'" ); - - auto_type res( static_cast<U*>( this->base()[idx] ) ); // nothrow - this->base()[idx] = r; // nothrow - return boost::ptr_container::move(res); // nothrow + auto_type res( static_cast<U*>(this->base()[idx]), *this ); // nothrow + this->base()[idx] = r; // nothrow + return boost::ptr_container::move(res); // nothrow } template< size_t idx, class V > @@ -167,14 +168,13 @@ namespace boost { this->enforce_null_policy( r, "Null pointer in 'ptr_array::replace()'" ); - auto_type ptr( r ); - + auto_type ptr( r, *this ); BOOST_PTR_CONTAINER_THROW_EXCEPTION( idx >= N, bad_index, "'replace()' aout of bounds" ); - auto_type res( static_cast<U*>( this->base()[idx] ) ); // nothrow - this->base()[idx] = ptr.release(); // nothrow - return boost::ptr_container::move(res); // nothrow + auto_type res( static_cast<U*>(this->base()[idx]), *this ); // nothrow + this->base()[idx] = ptr.release(); // nothrow + return boost::ptr_container::move(res); // nothrow } template< class V > diff --git a/boost/ptr_container/ptr_circular_buffer.hpp b/boost/ptr_container/ptr_circular_buffer.hpp index bfd1be603b..3421589be1 100644 --- a/boost/ptr_container/ptr_circular_buffer.hpp +++ b/boost/ptr_container/ptr_circular_buffer.hpp @@ -29,16 +29,17 @@ namespace boost class Allocator = std::allocator<void*> > class ptr_circular_buffer : public - ptr_sequence_adapter< T, - boost::circular_buffer<void*,Allocator>, + ptr_sequence_adapter< T, boost::circular_buffer< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > { - typedef ptr_sequence_adapter< T, - boost::circular_buffer<void*,Allocator>, + typedef ptr_sequence_adapter< T, boost::circular_buffer< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > base_type; - typedef boost::circular_buffer<void*,Allocator> circular_buffer_type; + typedef boost::circular_buffer<typename + ptr_container_detail::void_ptr<T>::type,Allocator> circular_buffer_type; typedef ptr_circular_buffer<T,CloneAllocator,Allocator> this_type; public: // typedefs @@ -264,7 +265,7 @@ namespace boost { ptr_circular_buffer temp( n ); for( size_type i = 0u; i != n; ++i ) - temp.push_back( this->null_policy_allocate_clone( to_clone ) ); + temp.push_back( temp.null_policy_allocate_clone( to_clone ) ); this->swap( temp ); } @@ -284,13 +285,13 @@ namespace boost void push_back( value_type ptr ) // nothrow { - BOOST_ASSERT( capacity() > 0 ); + BOOST_ASSERT( capacity() > 0 ); this->enforce_null_policy( ptr, "Null pointer in 'push_back()'" ); - auto_type old_ptr; + auto_type old_ptr( value_type(), *this ); if( full() ) - old_ptr.reset( &*this->begin() ); - this->base().push_back( ptr ); + old_ptr.reset( &*this->begin(), *this ); + this->base().push_back( ptr ); } template< class U > @@ -304,9 +305,9 @@ namespace boost BOOST_ASSERT( capacity() > 0 ); this->enforce_null_policy( ptr, "Null pointer in 'push_front()'" ); - auto_type old_ptr; + auto_type old_ptr( value_type(), *this ); if( full() ) - old_ptr.reset( &*(--this->end()) ); + old_ptr.reset( &*(--this->end()), *this ); this->base().push_front( ptr ); } @@ -321,16 +322,16 @@ namespace boost BOOST_ASSERT( capacity() > 0 ); this->enforce_null_policy( ptr, "Null pointer in 'insert()'" ); - auto_type new_ptr( ptr ); + auto_type new_ptr( ptr, *this ); iterator b = this->begin(); if( full() && pos == b ) return b; - auto_type old_ptr; + new_ptr.release(); + auto_type old_ptr( value_type(), *this ); if( full() ) - old_ptr.reset( &*this->begin() ); + old_ptr.reset( &*this->begin(), *this ); - new_ptr.release(); return this->base().insert( pos.base(), ptr ); } @@ -364,16 +365,16 @@ namespace boost BOOST_ASSERT( capacity() > 0 ); this->enforce_null_policy( ptr, "Null pointer in 'rinsert()'" ); - auto_type new_ptr( ptr ); + auto_type new_ptr( ptr, *this ); iterator b = this->end(); if (full() && pos == b) return b; - - auto_type old_ptr; + + new_ptr.release(); + auto_type old_ptr( value_type(), *this ); if( full() ) - old_ptr.reset( &this->back() ); + old_ptr.reset( &this->back(), *this ); - new_ptr.release(); return this->base().rinsert( pos.base(), ptr ); } @@ -485,7 +486,7 @@ namespace boost if( delete_from ) { BOOST_DEDUCED_TYPENAME base_type::scoped_deleter - deleter( from, size ); // nothrow + deleter( *this, from, size ); // nothrow for( size_type i = 0u; i != size; ++i, ++before ) before = insert( before, *(from+i) ); // nothrow deleter.release(); // nothrow diff --git a/boost/ptr_container/ptr_deque.hpp b/boost/ptr_container/ptr_deque.hpp index 0223fc79a4..8673962307 100644 --- a/boost/ptr_container/ptr_deque.hpp +++ b/boost/ptr_container/ptr_deque.hpp @@ -26,15 +26,15 @@ namespace boost < class T, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator<void*> + class Allocator = std::allocator<typename ptr_container_detail::void_ptr<T>::type> > class ptr_deque : public - ptr_sequence_adapter< T, - std::deque<void*,Allocator>, + ptr_sequence_adapter< T, std::deque< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > { - typedef ptr_sequence_adapter< T, - std::deque<void*,Allocator>, + typedef ptr_sequence_adapter< T, std::deque< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > base_class; diff --git a/boost/ptr_container/ptr_inserter.hpp b/boost/ptr_container/ptr_inserter.hpp index 71d1b60e70..b43e585994 100644 --- a/boost/ptr_container/ptr_inserter.hpp +++ b/boost/ptr_container/ptr_inserter.hpp @@ -65,10 +65,8 @@ namespace ptr_container ptr_back_insert_iterator& operator=( typename PtrContainer::value_type r ) { - typename PtrContainer::value_type obj = 0; - if( r != 0 ) - obj = container_type::clone_allocator_type::allocate_clone(*r); - + typename PtrContainer::value_type obj + = container->null_policy_allocate_clone(r); container->push_back( obj ); return *this; } @@ -84,8 +82,7 @@ namespace ptr_container ptr_back_insert_iterator& operator=( typename PtrContainer::const_reference r ) { - container->push_back( container_type::clone_allocator_type:: - allocate_clone(r) ); + container->push_back( container->null_policy_allocate_clone(&r) ); return *this; } @@ -125,10 +122,8 @@ namespace ptr_container ptr_front_insert_iterator& operator=( typename PtrContainer::value_type r ) { - typename PtrContainer::value_type obj = 0; - if( r != 0 ) - obj = container_type::clone_allocator_type::allocate_clone(*r); - + typename PtrContainer::value_type obj + = container->null_policy_allocate_clone(r); container->push_front( obj ); return *this; } @@ -144,8 +139,7 @@ namespace ptr_container ptr_front_insert_iterator& operator=( typename PtrContainer::const_reference r ) { - container->push_front( container_type::clone_allocator_type:: - allocate_clone(r) ); + container->push_front( container->null_policy_allocate_clone(&r) ); return *this; } @@ -186,9 +180,8 @@ namespace ptr_container ptr_insert_iterator& operator=( typename PtrContainer::value_type r ) { - typename PtrContainer::value_type obj = 0; - if( r != 0 ) - obj = container_type::clone_allocator_type::allocate_clone(*r); + typename PtrContainer::value_type obj = + container->null_policy_allocate_clone(r); iter = container->insert( iter, obj ); return *this; @@ -205,8 +198,8 @@ namespace ptr_container ptr_insert_iterator& operator=( typename PtrContainer::const_reference r ) { - iter = container->insert( iter, container_type::clone_allocator_type:: - allocate_clone(r) ); + iter = container->insert( iter, + container->null_policy_allocate_clone(&r) ); return *this; } diff --git a/boost/ptr_container/ptr_list.hpp b/boost/ptr_container/ptr_list.hpp index 7c900fa221..73c8e2b07b 100644 --- a/boost/ptr_container/ptr_list.hpp +++ b/boost/ptr_container/ptr_list.hpp @@ -26,19 +26,20 @@ namespace boost < class T, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator<void*> + class Allocator = std::allocator<typename ptr_container_detail::void_ptr<T>::type> > class ptr_list : public - ptr_sequence_adapter< T, - std::list<void*,Allocator>, + ptr_sequence_adapter< T, std::list< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > { - typedef ptr_sequence_adapter< T, - std::list<void*,Allocator>, + typedef ptr_sequence_adapter< T, std::list< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > base_class; typedef ptr_list<T,CloneAllocator,Allocator> this_type; + typedef BOOST_DEDUCED_TYPENAME boost::remove_nullable<T>::type U; public: BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_list, @@ -52,23 +53,23 @@ namespace boost void merge( ptr_list& x ) { - merge( x, std::less<T>() ); + merge( x, std::less<U>() ); } template< typename Compare > void merge( ptr_list& x, Compare comp ) { - this->base().merge( x.base(), void_ptr_indirect_fun<Compare,T>( comp ) ); } + this->base().merge( x.base(), void_ptr_indirect_fun<Compare,U>( comp ) ); } void sort() { - sort( std::less<T>() ); + sort( std::less<U>() ); }; template< typename Compare > void sort( Compare comp ) { - this->base().sort( void_ptr_indirect_fun<Compare,T>( comp ) ); + this->base().sort( void_ptr_indirect_fun<Compare,U>( comp ) ); } template< class Pred > diff --git a/boost/ptr_container/ptr_map.hpp b/boost/ptr_container/ptr_map.hpp index cbd39d7b1a..edacf0eb62 100644 --- a/boost/ptr_container/ptr_map.hpp +++ b/boost/ptr_container/ptr_map.hpp @@ -28,13 +28,15 @@ namespace boost class T, class Compare = std::less<Key>, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator< std::pair<const Key,void*> > + class Allocator = std::allocator< std::pair<const Key,typename ptr_container_detail::void_ptr<T>::type> > > class ptr_map : - public ptr_map_adapter<T,std::map<Key,void*, + public ptr_map_adapter<T,std::map<Key, + typename ptr_container_detail::void_ptr<T>::type, Compare,Allocator>,CloneAllocator> { - typedef ptr_map_adapter<T,std::map<Key,void*, + typedef ptr_map_adapter<T,std::map<Key, + typename ptr_container_detail::void_ptr<T>::type, Compare,Allocator>,CloneAllocator> base_type; diff --git a/boost/ptr_container/ptr_map_adapter.hpp b/boost/ptr_container/ptr_map_adapter.hpp index f3ce83af89..4754a94977 100644 --- a/boost/ptr_container/ptr_map_adapter.hpp +++ b/boost/ptr_container/ptr_map_adapter.hpp @@ -170,12 +170,10 @@ namespace ptr_container_detail const_mapped_reference lookup( const key_type& key ) const { const_iterator i = this->find( key ); - if( i != this->end() ) - return *i->second; - else - BOOST_PTR_CONTAINER_THROW_EXCEPTION( true, bad_ptr_container_operation, - "'ptr_map/multimap::at()' could" - " not find key" ); + BOOST_PTR_CONTAINER_THROW_EXCEPTION( i == this->end(), bad_ptr_container_operation, + "'ptr_map/multimap::at()' could" + " not find key" ); + return *i->second; } struct eraser // scope guard @@ -343,17 +341,15 @@ namespace ptr_container_detail auto_type replace( iterator where, mapped_type x ) // strong { BOOST_ASSERT( where != this->end() ); - this->enforce_null_policy( x, "Null pointer in 'replace()'" ); - auto_type ptr( x ); - + auto_type ptr( x, *this ); BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(), bad_ptr_container_operation, "'replace()' on empty container" ); - auto_type old( where->second ); // nothrow - where.base()->second = ptr.release(); // nothrow, commit + auto_type old( where->second, *this ); // nothrow + where.base()->second = ptr.release(); // nothrow, commit return boost::ptr_container::move( old ); } @@ -425,7 +421,7 @@ namespace ptr_container_detail if( this->find( first->first ) == this->end() ) { const_reference p = *first.base(); // nothrow - auto_type ptr( this->null_policy_allocate_clone( p.second ) ); + auto_type ptr( this->null_policy_allocate_clone(p.second), *this ); // strong this->safe_insert( p.first, boost::ptr_container::move( ptr ) ); @@ -444,6 +440,11 @@ namespace ptr_container_detail const allocator_type& a ) : base_type( comp, a ) { } + template< class SizeType > + explicit ptr_map_adapter( SizeType n, + ptr_container_detail::unordered_associative_container_tag tag ) + : base_type( n, tag ) { } + template< class Hash, class Pred, class Allocator > ptr_map_adapter( const Hash& hash, const Pred& pred, @@ -522,8 +523,8 @@ namespace ptr_container_detail std::pair<iterator,bool> insert_impl( const key_type& key, mapped_type x ) // strong { this->enforce_null_policy( x, "Null pointer in ptr_map_adapter::insert()" ); - auto_type ptr( x ); // nothrow + auto_type ptr( x, *this ); // nothrow std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> res = this->base().insert( std::make_pair( key, x ) ); // strong, commit if( res.second ) // nothrow @@ -535,7 +536,8 @@ namespace ptr_container_detail { this->enforce_null_policy( x, "Null pointer in 'ptr_map_adapter::insert()'" ); - auto_type ptr( x ); // nothrow + + auto_type ptr( x, *this ); // nothrow BOOST_DEDUCED_TYPENAME base_type::ptr_iterator res = this->base().insert( before.base(), std::make_pair( key, x ) ); // strong, commit @@ -562,7 +564,7 @@ namespace ptr_container_detail this->enforce_null_policy( p.second, "Null pointer in 'ptr_map_adapter::insert()'" ); - auto_type ptr( this->null_policy_allocate_clone( p.second ) ); + auto_type ptr( this->null_policy_allocate_clone(p.second), *this ); BOOST_DEDUCED_TYPENAME base_type::ptr_iterator result = this->base().insert( before.base(), std::make_pair(p.first,ptr.get()) ); // strong @@ -668,7 +670,7 @@ namespace ptr_container_detail while( first != last ) { const_reference pair = *first.base(); // nothrow - auto_type ptr( this->null_policy_allocate_clone( pair.second ) ); + auto_type ptr( this->null_policy_allocate_clone(pair.second), *this ); // strong safe_insert( pair.first, boost::ptr_container::move( ptr ) ); @@ -760,7 +762,8 @@ namespace ptr_container_detail { this->enforce_null_policy( x, "Null pointer in 'ptr_multimap_adapter::insert()'" ); - auto_type ptr( x ); // nothrow + + auto_type ptr( x, *this ); // nothrow BOOST_DEDUCED_TYPENAME base_type::ptr_iterator res = this->base().insert( std::make_pair( key, x ) ); // strong, commit @@ -772,7 +775,8 @@ namespace ptr_container_detail { this->enforce_null_policy( x, "Null pointer in 'ptr_multimap_adapter::insert()'" ); - auto_type ptr( x ); // nothrow + + auto_type ptr( x, *this ); // nothrow BOOST_DEDUCED_TYPENAME base_type::ptr_iterator res = this->base().insert( before.base(), std::make_pair( key, x ) ); diff --git a/boost/ptr_container/ptr_sequence_adapter.hpp b/boost/ptr_container/ptr_sequence_adapter.hpp index a7717ed8e8..fceab26053 100644 --- a/boost/ptr_container/ptr_sequence_adapter.hpp +++ b/boost/ptr_container/ptr_sequence_adapter.hpp @@ -244,8 +244,7 @@ namespace ptr_container_detail void push_back( value_type x ) // strong { this->enforce_null_policy( x, "Null pointer in 'push_back()'" ); - - auto_type ptr( x ); // notrow + auto_type ptr( x, *this ); // notrow this->base().push_back( x ); // strong, commit ptr.release(); // nothrow } @@ -259,8 +258,7 @@ namespace ptr_container_detail void push_front( value_type x ) { this->enforce_null_policy( x, "Null pointer in 'push_front()'" ); - - auto_type ptr( x ); // nothrow + auto_type ptr( x, *this ); // nothrow this->base().push_front( x ); // strong, commit ptr.release(); // nothrow } @@ -275,7 +273,7 @@ namespace ptr_container_detail { BOOST_ASSERT( !this->empty() && "'pop_back()' on empty container" ); - auto_type ptr( static_cast<value_type>( this->base().back() ) ); + auto_type ptr( static_cast<value_type>(this->base().back()), *this ); // nothrow this->base().pop_back(); // nothrow return ptr_container_detail::move( ptr ); // nothrow @@ -285,7 +283,7 @@ namespace ptr_container_detail { BOOST_ASSERT( !this->empty() && "'pop_front()' on empty container" ); - auto_type ptr( static_cast<value_type>( this->base().front() ) ); + auto_type ptr( static_cast<value_type>(this->base().front()), *this ); // nothrow this->base().pop_front(); // nothrow return ptr_container_detail::move( ptr ); @@ -396,7 +394,7 @@ namespace ptr_container_detail { if( first == last ) return; - scoped_deleter sd( first, last ); // strong + scoped_deleter sd( *this, first, last ); // strong this->insert_clones_and_release( sd, before ); // strong, commit } @@ -482,7 +480,7 @@ namespace ptr_container_detail if( delete_from ) { BOOST_DEDUCED_TYPENAME base_type::scoped_deleter - deleter( from, size ); // nothrow + deleter( *this, from, size ); // nothrow this->base().insert( before.base(), from, from + size ); // strong deleter.release(); // nothrow } @@ -664,7 +662,7 @@ namespace ptr_container_detail } - void range_check_impl( iterator first, iterator last, + void range_check_impl( iterator, iterator, std::bidirectional_iterator_tag ) { /* do nothing */ } diff --git a/boost/ptr_container/ptr_set.hpp b/boost/ptr_container/ptr_set.hpp index 74bfa41210..3e6b7e374d 100644 --- a/boost/ptr_container/ptr_set.hpp +++ b/boost/ptr_container/ptr_set.hpp @@ -28,14 +28,17 @@ namespace boost class Key, class Compare = std::less<Key>, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator<void*> + class Allocator = std::allocator<typename ptr_container_detail::void_ptr<Key>::type> > class ptr_set : - public ptr_set_adapter< Key, - std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>, + public ptr_set_adapter< Key, std::set< + typename ptr_container_detail::void_ptr<Key>::type, + void_ptr_indirect_fun<Compare,Key>,Allocator>, CloneAllocator, true > { - typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>, + typedef ptr_set_adapter< Key, std::set< + typename ptr_container_detail::void_ptr<Key>::type, + void_ptr_indirect_fun<Compare,Key>,Allocator>, CloneAllocator, true > base_type; diff --git a/boost/ptr_container/ptr_set_adapter.hpp b/boost/ptr_container/ptr_set_adapter.hpp index 4b6aacd604..9274fd9bda 100644 --- a/boost/ptr_container/ptr_set_adapter.hpp +++ b/boost/ptr_container/ptr_set_adapter.hpp @@ -323,7 +323,7 @@ namespace ptr_container_detail while( first != last ) { if( this->find( *first ) == this->end() ) - insert( CloneAllocator::allocate_clone( *first ) ); // strong, commit + insert( this->null_policy_allocate_clone_from_iterator( first ) ); // strong, commit ++first; } } @@ -346,6 +346,14 @@ namespace ptr_container_detail BOOST_ASSERT( this->empty() ); } + template< class SizeType, class Hash, class Pred, class Allocator > + ptr_set_adapter( SizeType n, + const Hash& hash, + const Pred& pred, + const Allocator& a ) + : base_type( n, hash, pred, a ) + { } + template< class Hash, class Pred, class Allocator > ptr_set_adapter( const Hash& hash, const Pred& pred, @@ -407,7 +415,7 @@ namespace ptr_container_detail { this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" ); - auto_type ptr( x ); + auto_type ptr( x, *this ); std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> res = this->base().insert( x ); if( res.second ) @@ -426,7 +434,7 @@ namespace ptr_container_detail { this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" ); - auto_type ptr( x ); + auto_type ptr( x, *this ); BOOST_DEDUCED_TYPENAME base_type::ptr_iterator res = this->base().insert( where.base(), x ); if( *res == x ) @@ -530,7 +538,7 @@ namespace ptr_container_detail { while( first != last ) { - insert( CloneAllocator::allocate_clone( *first ) ); // strong, commit + insert( this->null_policy_allocate_clone_from_iterator( first ) ); // strong, commit ++first; } } @@ -618,7 +626,7 @@ namespace ptr_container_detail { this->enforce_null_policy( x, "Null pointer in 'ptr_multiset::insert()'" ); - auto_type ptr( x ); + auto_type ptr( x, *this ); BOOST_DEDUCED_TYPENAME base_type::ptr_iterator res = this->base().insert( x ); ptr.release(); diff --git a/boost/ptr_container/ptr_unordered_map.hpp b/boost/ptr_container/ptr_unordered_map.hpp index b881584a42..e6d5e7d5ba 100644 --- a/boost/ptr_container/ptr_unordered_map.hpp +++ b/boost/ptr_container/ptr_unordered_map.hpp @@ -29,13 +29,16 @@ namespace boost class Hash = boost::hash<Key>, class Pred = std::equal_to<Key>, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator< std::pair<const Key,void*> > + class Allocator = std::allocator< std::pair<const Key, + typename ptr_container_detail::void_ptr<T>::type> > > class ptr_unordered_map : - public ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>, + public ptr_map_adapter<T,boost::unordered_map<Key, + typename ptr_container_detail::void_ptr<T>::type,Hash,Pred,Allocator>, CloneAllocator,false> { - typedef ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>, + typedef ptr_map_adapter<T,boost::unordered_map<Key, + typename ptr_container_detail::void_ptr<T>::type,Hash,Pred,Allocator>, CloneAllocator,false> base_type; diff --git a/boost/ptr_container/ptr_unordered_set.hpp b/boost/ptr_container/ptr_unordered_set.hpp index 49ec464ebb..90f1c60e23 100644 --- a/boost/ptr_container/ptr_unordered_set.hpp +++ b/boost/ptr_container/ptr_unordered_set.hpp @@ -29,16 +29,18 @@ namespace boost class Hash = boost::hash<Key>, class Pred = std::equal_to<Key>, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator<void*> + class Allocator = std::allocator< typename ptr_container_detail::void_ptr<Key>::type > > class ptr_unordered_set : - public ptr_set_adapter< Key, - boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>, - void_ptr_indirect_fun<Pred,Key>,Allocator>, + public ptr_set_adapter< Key, boost::unordered_set< + typename ptr_container_detail::void_ptr<Key>::type, + void_ptr_indirect_fun<Hash,Key>, + void_ptr_indirect_fun<Pred,Key>,Allocator>, CloneAllocator, false > { - typedef ptr_set_adapter< Key, - boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>, + typedef ptr_set_adapter< Key, boost::unordered_set< + typename ptr_container_detail::void_ptr<Key>::type, + void_ptr_indirect_fun<Hash,Key>, void_ptr_indirect_fun<Pred,Key>,Allocator>, CloneAllocator, false > base_type; diff --git a/boost/ptr_container/ptr_vector.hpp b/boost/ptr_container/ptr_vector.hpp index ee42095bce..5a85ad9c52 100644 --- a/boost/ptr_container/ptr_vector.hpp +++ b/boost/ptr_container/ptr_vector.hpp @@ -26,15 +26,15 @@ namespace boost < class T, class CloneAllocator = heap_clone_allocator, - class Allocator = std::allocator<void*> + class Allocator = std::allocator<typename ptr_container_detail::void_ptr<T>::type> > class ptr_vector : public - ptr_sequence_adapter< T, - std::vector<void*,Allocator>, + ptr_sequence_adapter< T, std::vector< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > { - typedef ptr_sequence_adapter< T, - std::vector<void*,Allocator>, + typedef ptr_sequence_adapter< T, std::vector< + typename ptr_container_detail::void_ptr<T>::type,Allocator>, CloneAllocator > base_class; |