update boost on linux
This commit is contained in:
@@ -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 )
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
#endif
|
||||
|
||||
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -103,10 +109,18 @@ namespace ptr_container_detail
|
||||
: base_type( first, last, hash, pred, a )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit associative_ptr_container( std::auto_ptr<PtrContainer> r )
|
||||
: base_type( r )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit associative_ptr_container( std::unique_ptr<PtrContainer> r )
|
||||
: base_type( std::move( r ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
associative_ptr_container( const associative_ptr_container& r )
|
||||
: base_type( r.begin(), r.end(), container_type() )
|
||||
@@ -117,12 +131,22 @@ namespace ptr_container_detail
|
||||
: base_type( r.begin(), r.end(), container_type() )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
associative_ptr_container& operator=( std::auto_ptr<PtrContainer> r ) // nothrow
|
||||
{
|
||||
base_type::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
associative_ptr_container& operator=( std::unique_ptr<PtrContainer> r ) // nothrow
|
||||
{
|
||||
base_type::operator=( std::move( r ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
associative_ptr_container& operator=( associative_ptr_container r ) // strong
|
||||
{
|
||||
@@ -407,5 +431,8 @@ namespace ptr_container_detail
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef BOOST_PTR_CONTAINER_DETAIL_PTR_CONTAINER_DISABLE_DEPRECATED_HPP_INCLUDED
|
||||
#define BOOST_PTR_CONTAINER_DETAIL_PTR_CONTAINER_DISABLE_DEPRECATED_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/ptr_container/detail/ptr_container_disable_deprecated.hpp
|
||||
//
|
||||
// Copyright 2015 Peter Dimov
|
||||
//
|
||||
// Distributed under 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)
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined( __GNUC__ ) && ( defined( __GXX_EXPERIMENTAL_CXX0X__ ) || ( __cplusplus >= 201103L ) ) && !defined(BOOST_NO_AUTO_PTR)
|
||||
|
||||
# if defined( BOOST_GCC )
|
||||
|
||||
# if BOOST_GCC >= 40600
|
||||
# define BOOST_PTR_CONTAINER_DISABLE_DEPRECATED
|
||||
# endif
|
||||
|
||||
# elif defined( __clang__ ) && defined( __has_warning )
|
||||
|
||||
# if __has_warning( "-Wdeprecated-declarations" )
|
||||
# define BOOST_PTR_CONTAINER_DISABLE_DEPRECATED
|
||||
# endif
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_PTR_CONTAINER_DETAIL_PTR_CONTAINER_DISABLE_DEPRECATED_HPP_INCLUDED
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/ptr_container/detail/throw_exception.hpp>
|
||||
#include <boost/ptr_container/detail/scoped_deleter.hpp>
|
||||
#include <boost/ptr_container/detail/static_move_ptr.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <boost/ptr_container/exception.hpp>
|
||||
#include <boost/ptr_container/clone_allocator.hpp>
|
||||
#include <boost/ptr_container/nullable.hpp>
|
||||
@@ -35,25 +36,52 @@
|
||||
#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
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace ptr_container_detail
|
||||
{
|
||||
template< class CloneAllocator >
|
||||
struct clone_deleter
|
||||
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 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 +107,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 );
|
||||
|
||||
BOOST_STATIC_CONSTANT( bool, is_clone_allocator_empty = sizeof(CloneAllocator) < sizeof(void*) );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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::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 +140,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 +172,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 +187,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 +196,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 +228,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 +253,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 +305,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 +324,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()
|
||||
{ }
|
||||
|
||||
@@ -336,12 +351,21 @@ namespace ptr_container_detail
|
||||
explicit reversible_ptr_container( const allocator_type& a )
|
||||
: c_( a )
|
||||
{ }
|
||||
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit reversible_ptr_container( std::auto_ptr<PtrContainer> clone )
|
||||
{
|
||||
swap( *clone );
|
||||
explicit reversible_ptr_container( std::auto_ptr<PtrContainer> clone )
|
||||
{
|
||||
swap( *clone );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit reversible_ptr_container( std::unique_ptr<PtrContainer> clone )
|
||||
{
|
||||
swap( *clone );
|
||||
}
|
||||
#endif
|
||||
|
||||
reversible_ptr_container( const reversible_ptr_container& r )
|
||||
{
|
||||
@@ -354,12 +378,22 @@ namespace ptr_container_detail
|
||||
constructor_impl( r.begin(), r.end(), std::forward_iterator_tag() );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
reversible_ptr_container& operator=( std::auto_ptr<PtrContainer> clone ) // nothrow
|
||||
{
|
||||
swap( *clone );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
reversible_ptr_container& operator=( std::unique_ptr<PtrContainer> clone ) // nothrow
|
||||
{
|
||||
swap( *clone );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
reversible_ptr_container& operator=( reversible_ptr_container r ) // strong
|
||||
{
|
||||
@@ -471,6 +505,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 +547,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,17 +607,26 @@ 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;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, std::auto_ptr<U> x )
|
||||
{
|
||||
return insert( before, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, std::unique_ptr<U> x )
|
||||
{
|
||||
return insert( before, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
iterator erase( iterator x ) // nothrow
|
||||
{
|
||||
@@ -611,52 +665,67 @@ 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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
auto_type replace( iterator where, std::auto_ptr<U> x )
|
||||
{
|
||||
return replace( where, x.release() );
|
||||
return replace( where, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
auto_type replace( iterator where, std::unique_ptr<U> x )
|
||||
{
|
||||
return replace( where, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
auto_type replace( size_type idx, std::auto_ptr<U> x )
|
||||
{
|
||||
return replace( idx, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
auto_type replace( size_type idx, std::unique_ptr<U> x )
|
||||
{
|
||||
return replace( idx, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
}; // 'reversible_ptr_container'
|
||||
|
||||
@@ -672,12 +741,9 @@ namespace ptr_container_detail
|
||||
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \
|
||||
using base_type::release;
|
||||
#endif
|
||||
|
||||
//
|
||||
// two-phase lookup of template functions
|
||||
// is buggy on most compilers, so we use a macro instead
|
||||
//
|
||||
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type ) \
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
#define BOOST_PTR_CONTAINER_COPY_AND_ASSIGN_AUTO( PC, base_type, this_type ) \
|
||||
explicit PC( std::auto_ptr<this_type> r ) \
|
||||
: base_type ( r ) { } \
|
||||
\
|
||||
@@ -685,20 +751,64 @@ namespace ptr_container_detail
|
||||
{ \
|
||||
base_type::operator=( r ); \
|
||||
return *this; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define BOOST_PTR_CONTAINER_COPY_AND_ASSIGN_AUTO( PC, base_type, this_type )
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
#define BOOST_PTR_CONTAINER_COPY_AND_ASSIGN_UNIQUE( PC, base_type, this_type ) \
|
||||
explicit PC( std::unique_ptr<this_type> r ) \
|
||||
: base_type ( std::move( r ) ) { } \
|
||||
\
|
||||
PC& operator=( std::unique_ptr<this_type> r ) \
|
||||
{ \
|
||||
base_type::operator=( std::move( r ) ); \
|
||||
return *this; \
|
||||
}
|
||||
#else
|
||||
#define BOOST_PTR_CONTAINER_COPY_AND_ASSIGN_UNIQUE( PC, base_type, this_type )
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
#define BOOST_PTR_CONTAINER_RELEASE_AND_CLONE( this_type ) \
|
||||
std::auto_ptr<this_type> release() \
|
||||
{ \
|
||||
std::auto_ptr<this_type> ptr( new this_type );\
|
||||
this->swap( *ptr ); \
|
||||
return ptr; \
|
||||
} \
|
||||
BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \
|
||||
\
|
||||
std::auto_ptr<this_type> clone() const \
|
||||
{ \
|
||||
return std::auto_ptr<this_type>( new this_type( this->begin(), this->end() ) ); \
|
||||
}
|
||||
#elif !defined( BOOST_NO_CXX11_SMART_PTR )
|
||||
#define BOOST_PTR_CONTAINER_RELEASE_AND_CLONE( this_type ) \
|
||||
std::unique_ptr<this_type> release() \
|
||||
{ \
|
||||
std::unique_ptr<this_type> ptr( new this_type );\
|
||||
this->swap( *ptr ); \
|
||||
return ptr; \
|
||||
} \
|
||||
\
|
||||
std::unique_ptr<this_type> clone() const \
|
||||
{ \
|
||||
return std::unique_ptr<this_type>( new this_type( this->begin(), this->end() ) ); \
|
||||
}
|
||||
#else
|
||||
#define BOOST_PTR_CONTAINER_RELEASE_AND_CLONE( this_type )
|
||||
#endif
|
||||
|
||||
//
|
||||
// two-phase lookup of template functions
|
||||
// is buggy on most compilers, so we use a macro instead
|
||||
//
|
||||
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type ) \
|
||||
BOOST_PTR_CONTAINER_COPY_AND_ASSIGN_AUTO( PC, base_type, this_type ) \
|
||||
BOOST_PTR_CONTAINER_COPY_AND_ASSIGN_UNIQUE( PC, base_type, this_type ) \
|
||||
BOOST_PTR_CONTAINER_RELEASE_AND_CLONE( this_type ) \
|
||||
BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type )
|
||||
|
||||
#define BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type ) \
|
||||
\
|
||||
@@ -745,6 +855,10 @@ namespace ptr_container_detail
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@@ -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] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -56,12 +62,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 +96,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 >
|
||||
@@ -100,8 +108,14 @@ namespace boost
|
||||
static_cast<const T*>( &r[i] ) );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
explicit ptr_array( std::auto_ptr<this_type> r )
|
||||
: base_class( r ) { }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
explicit ptr_array( std::unique_ptr<this_type> r )
|
||||
: base_class( std::move( r ) ) { }
|
||||
#endif
|
||||
|
||||
ptr_array& operator=( ptr_array r )
|
||||
{
|
||||
@@ -109,12 +123,22 @@ namespace boost
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
ptr_array& operator=( std::auto_ptr<this_type> r )
|
||||
{
|
||||
base_class::operator=(r);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
ptr_array& operator=( std::unique_ptr<this_type> r )
|
||||
{
|
||||
base_class::operator=(std::move(r));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
std::auto_ptr<this_type> release()
|
||||
{
|
||||
std::auto_ptr<this_type> ptr( new this_type );
|
||||
@@ -125,12 +149,32 @@ namespace boost
|
||||
std::auto_ptr<this_type> clone() const
|
||||
{
|
||||
std::auto_ptr<this_type> pa( new this_type );
|
||||
clone_array_elements( *pa );
|
||||
return pa;
|
||||
}
|
||||
#else
|
||||
std::unique_ptr<this_type> release()
|
||||
{
|
||||
std::unique_ptr<this_type> ptr( new this_type );
|
||||
this->swap( *ptr );
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<this_type> clone() const
|
||||
{
|
||||
std::unique_ptr<this_type> pa( new this_type );
|
||||
clone_array_elements( *pa );
|
||||
return pa;
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
void clone_array_elements( this_type &pa ) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
private: // hide some members
|
||||
@@ -151,37 +195,53 @@ 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
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< size_t idx, class V >
|
||||
auto_type replace( std::auto_ptr<V> r )
|
||||
{
|
||||
return replace<idx>( r.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< size_t idx, class V >
|
||||
auto_type replace( std::unique_ptr<V> r )
|
||||
{
|
||||
return replace<idx>( r.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
auto_type replace( size_t idx, U* r ) // strong
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class V >
|
||||
auto_type replace( size_t idx, std::auto_ptr<V> r )
|
||||
{
|
||||
return replace( idx, r.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class V >
|
||||
auto_type replace( size_t idx, std::unique_ptr<V> r )
|
||||
{
|
||||
return replace( idx, r.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
using base_class::at;
|
||||
|
||||
@@ -231,4 +291,8 @@ namespace boost
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -29,16 +36,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 +272,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,61 +292,88 @@ 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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
void push_back( std::auto_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
push_back( ptr.release() );
|
||||
push_back( ptr.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
void push_back( std::unique_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
push_back( ptr.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
void push_front( value_type ptr ) // nothrow
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
void push_front( std::auto_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
push_front( ptr.release() );
|
||||
push_front( ptr.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
void push_front( std::unique_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
push_front( ptr.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
iterator insert( iterator pos, value_type ptr ) // nothrow
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator pos, std::auto_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
return insert( pos, ptr.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator pos, std::unique_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
return insert( pos, ptr.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class InputIterator >
|
||||
void insert( iterator pos, InputIterator first, InputIterator last ) // basic
|
||||
@@ -364,24 +399,33 @@ 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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator rinsert( iterator pos, std::auto_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
return rinsert( pos, ptr.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator rinsert( iterator pos, std::unique_ptr<U> ptr ) // nothrow
|
||||
{
|
||||
return rinsert( pos, ptr.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template< class InputIterator >
|
||||
@@ -485,7 +529,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
|
||||
@@ -528,4 +572,8 @@ namespace boost
|
||||
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
#include <deque>
|
||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -26,15 +32,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;
|
||||
|
||||
@@ -66,4 +72,8 @@ namespace boost
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,9 +17,15 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace ptr_container
|
||||
@@ -51,10 +57,14 @@ namespace ptr_container
|
||||
|
||||
|
||||
template< class PtrContainer >
|
||||
class ptr_back_insert_iterator :
|
||||
public std::iterator<std::output_iterator_tag,void,void,void,void>
|
||||
class ptr_back_insert_iterator
|
||||
{
|
||||
public:
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
typedef PtrContainer container_type;
|
||||
|
||||
public:
|
||||
@@ -65,14 +75,13 @@ 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;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class T >
|
||||
ptr_back_insert_iterator&
|
||||
operator=( std::auto_ptr<T> r )
|
||||
@@ -80,12 +89,21 @@ namespace ptr_container
|
||||
container->push_back( r );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class T >
|
||||
ptr_back_insert_iterator&
|
||||
operator=( std::unique_ptr<T> r )
|
||||
{
|
||||
container->push_back( std::move( r ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -111,10 +129,14 @@ namespace ptr_container
|
||||
|
||||
|
||||
template< class PtrContainer >
|
||||
class ptr_front_insert_iterator :
|
||||
public std::iterator<std::output_iterator_tag,void,void,void,void>
|
||||
class ptr_front_insert_iterator
|
||||
{
|
||||
public:
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
typedef PtrContainer container_type;
|
||||
|
||||
public:
|
||||
@@ -125,14 +147,13 @@ 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;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class T >
|
||||
ptr_front_insert_iterator&
|
||||
operator=( std::auto_ptr<T> r )
|
||||
@@ -140,12 +161,21 @@ namespace ptr_container
|
||||
container->push_front( r );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class T >
|
||||
ptr_front_insert_iterator&
|
||||
operator=( std::unique_ptr<T> r )
|
||||
{
|
||||
container->push_front( std::move( r ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -171,10 +201,14 @@ namespace ptr_container
|
||||
|
||||
|
||||
template< class PtrContainer >
|
||||
class ptr_insert_iterator :
|
||||
public std::iterator<std::output_iterator_tag,void,void,void,void>
|
||||
class ptr_insert_iterator
|
||||
{
|
||||
public:
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
typedef PtrContainer container_type;
|
||||
|
||||
public:
|
||||
@@ -186,14 +220,14 @@ 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;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class T >
|
||||
ptr_insert_iterator&
|
||||
operator=( std::auto_ptr<T> r )
|
||||
@@ -201,12 +235,22 @@ namespace ptr_container
|
||||
iter = container->insert( iter, r );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class T >
|
||||
ptr_insert_iterator&
|
||||
operator=( std::unique_ptr<T> r )
|
||||
{
|
||||
iter = container->insert( iter, std::move( r ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -255,4 +299,8 @@ namespace ptr_container
|
||||
} // namespace 'ptr_container'
|
||||
} // namespace 'boost'
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,8 +17,14 @@
|
||||
#endif
|
||||
|
||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <list>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@@ -26,19 +32,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 +59,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 >
|
||||
@@ -106,5 +113,8 @@ namespace boost
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
#include <map>
|
||||
#include <boost/ptr_container/ptr_map_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -28,13 +34,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;
|
||||
|
||||
@@ -162,4 +170,8 @@ namespace boost
|
||||
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,9 +19,15 @@
|
||||
#include <boost/ptr_container/detail/map_iterator.hpp>
|
||||
#include <boost/ptr_container/detail/associative_ptr_container.hpp>
|
||||
#include <boost/ptr_container/detail/meta_functions.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace ptr_container_detail
|
||||
@@ -170,12 +176,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
|
||||
@@ -261,17 +265,32 @@ namespace ptr_container_detail
|
||||
: base_type( first, last, hash, pred, a )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_map_adapter_base( std::auto_ptr<PtrContainer> clone )
|
||||
explicit ptr_map_adapter_base( std::auto_ptr<PtrContainer> clone )
|
||||
: base_type( clone )
|
||||
{ }
|
||||
|
||||
|
||||
template< typename PtrContainer >
|
||||
ptr_map_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
|
||||
ptr_map_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
|
||||
{
|
||||
base_type::operator=( clone );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_map_adapter_base( std::unique_ptr<PtrContainer> clone )
|
||||
: base_type( std::move( clone ) )
|
||||
{ }
|
||||
|
||||
template< typename PtrContainer >
|
||||
ptr_map_adapter_base& operator=( std::unique_ptr<PtrContainer> clone )
|
||||
{
|
||||
base_type::operator=( std::move( clone ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
iterator find( const key_type& x )
|
||||
{
|
||||
@@ -343,25 +362,32 @@ 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 );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
auto_type replace( iterator where, std::auto_ptr<U> x )
|
||||
{
|
||||
return replace( where, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
auto_type replace( iterator where, std::unique_ptr<U> x )
|
||||
{
|
||||
return replace( where, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
size_type bucket( const key_type& key ) const
|
||||
@@ -425,7 +451,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 +470,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,
|
||||
@@ -487,9 +518,16 @@ namespace ptr_container_detail
|
||||
map_basic_clone_and_insert( r.begin(), r.end() );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
ptr_map_adapter( std::auto_ptr<U> r ) : base_type( r )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
ptr_map_adapter( std::unique_ptr<U> r ) : base_type( std::move( r ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
ptr_map_adapter& operator=( ptr_map_adapter r )
|
||||
{
|
||||
@@ -497,12 +535,22 @@ namespace ptr_container_detail
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
ptr_map_adapter& operator=( std::auto_ptr<U> r )
|
||||
{
|
||||
{
|
||||
base_type::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
ptr_map_adapter& operator=( std::unique_ptr<U> r )
|
||||
{
|
||||
base_type::operator=( std::move( r ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
using base_type::release;
|
||||
|
||||
@@ -522,8 +570,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 +583,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
|
||||
@@ -550,11 +599,20 @@ namespace ptr_container_detail
|
||||
return insert_impl( key, x );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
std::pair<iterator,bool> insert( const key_type& key, std::auto_ptr<U> x )
|
||||
{
|
||||
return insert_impl( key, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
std::pair<iterator,bool> insert( const key_type& key, std::unique_ptr<U> x )
|
||||
{
|
||||
return insert_impl( key, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class F, class S >
|
||||
iterator insert( iterator before, ptr_container_detail::ref_pair<F,S> p ) // strong
|
||||
@@ -562,7 +620,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
|
||||
@@ -577,11 +635,20 @@ namespace ptr_container_detail
|
||||
return insert_impl( before, key, x );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, const key_type& key, std::auto_ptr<U> x ) // strong
|
||||
{
|
||||
return insert_impl( before, key, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, const key_type& key, std::unique_ptr<U> x ) // strong
|
||||
{
|
||||
return insert_impl( before, key, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class PtrMapAdapter >
|
||||
bool transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object,
|
||||
@@ -668,7 +735,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 ) );
|
||||
@@ -736,9 +803,16 @@ namespace ptr_container_detail
|
||||
map_basic_clone_and_insert( r.begin(), r.end() );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
explicit ptr_multimap_adapter( std::auto_ptr<U> r ) : base_type( r )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
explicit ptr_multimap_adapter( std::unique_ptr<U> r ) : base_type( std::move( r ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
ptr_multimap_adapter& operator=( ptr_multimap_adapter r )
|
||||
{
|
||||
@@ -746,12 +820,22 @@ namespace ptr_container_detail
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
ptr_multimap_adapter& operator=( std::auto_ptr<U> r )
|
||||
{
|
||||
base_type::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
ptr_multimap_adapter& operator=( std::unique_ptr<U> r )
|
||||
{
|
||||
base_type::operator=( std::move( r ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
using base_type::release;
|
||||
|
||||
@@ -760,7 +844,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 +857,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 ) );
|
||||
@@ -799,11 +885,20 @@ namespace ptr_container_detail
|
||||
return insert_impl( key, x );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( const key_type& key, std::auto_ptr<U> x )
|
||||
{
|
||||
return insert_impl( key, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( const key_type& key, std::unique_ptr<U> x )
|
||||
{
|
||||
return insert_impl( key, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class F, class S >
|
||||
iterator insert( iterator before, ptr_container_detail::ref_pair<F,S> p ) // strong
|
||||
@@ -820,11 +915,20 @@ namespace ptr_container_detail
|
||||
return insert_impl( before, key, x );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, const key_type& key, std::auto_ptr<U> x ) // strong
|
||||
{
|
||||
return insert_impl( before, key, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, const key_type& key, std::unique_ptr<U> x ) // strong
|
||||
{
|
||||
return insert_impl( before, key, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class PtrMapAdapter >
|
||||
void transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object,
|
||||
@@ -871,4 +975,8 @@ namespace ptr_container_detail
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,9 +20,15 @@
|
||||
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
|
||||
#include <boost/ptr_container/indirect_fun.hpp>
|
||||
#include <boost/ptr_container/detail/void_ptr_iterator.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -219,10 +225,18 @@ namespace ptr_container_detail
|
||||
: base_type( r, tag )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_sequence_adapter( std::auto_ptr<PtrContainer> clone )
|
||||
: base_type( clone )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_sequence_adapter( std::unique_ptr<PtrContainer> clone )
|
||||
: base_type( std::move( clone ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
ptr_sequence_adapter& operator=( const ptr_sequence_adapter r )
|
||||
{
|
||||
@@ -230,12 +244,22 @@ namespace ptr_container_detail
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
ptr_sequence_adapter& operator=( std::auto_ptr<PtrContainer> clone )
|
||||
ptr_sequence_adapter& operator=( std::auto_ptr<PtrContainer> clone )
|
||||
{
|
||||
base_type::operator=( clone );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
ptr_sequence_adapter& operator=( std::unique_ptr<PtrContainer> clone )
|
||||
{
|
||||
base_type::operator=( std::move( clone ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// modifiers
|
||||
@@ -244,38 +268,54 @@ 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
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
void push_back( std::auto_ptr<U> x )
|
||||
{
|
||||
push_back( x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
void push_back( std::unique_ptr<U> x )
|
||||
{
|
||||
push_back( x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
void push_front( std::auto_ptr<U> x )
|
||||
{
|
||||
push_front( x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
void push_front( std::unique_ptr<U> x )
|
||||
{
|
||||
push_front( x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
auto_type pop_back()
|
||||
{
|
||||
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 +325,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 +436,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 +522,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 +704,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 */ }
|
||||
|
||||
@@ -772,4 +812,8 @@ namespace ptr_container_detail
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,14 @@
|
||||
|
||||
#include <boost/ptr_container/indirect_fun.hpp>
|
||||
#include <boost/ptr_container/ptr_set_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <set>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@@ -28,14 +34,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;
|
||||
|
||||
@@ -152,4 +161,8 @@ namespace boost
|
||||
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,14 @@
|
||||
#include <boost/ptr_container/detail/associative_ptr_container.hpp>
|
||||
#include <boost/ptr_container/detail/meta_functions.hpp>
|
||||
#include <boost/ptr_container/detail/void_ptr_iterator.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace ptr_container_detail
|
||||
@@ -182,10 +188,18 @@ namespace ptr_container_detail
|
||||
: base_type( r )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_set_adapter_base( std::auto_ptr<PtrContainer> clone )
|
||||
: base_type( clone )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_set_adapter_base( std::unique_ptr<PtrContainer> clone )
|
||||
: base_type( std::move( clone ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
ptr_set_adapter_base& operator=( ptr_set_adapter_base r )
|
||||
{
|
||||
@@ -193,12 +207,22 @@ namespace ptr_container_detail
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< typename PtrContainer >
|
||||
ptr_set_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
|
||||
ptr_set_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
|
||||
{
|
||||
base_type::operator=( clone );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< typename PtrContainer >
|
||||
ptr_set_adapter_base& operator=( std::unique_ptr<PtrContainer> clone )
|
||||
{
|
||||
base_type::operator=( std::move( clone ) );
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
using base_type::erase;
|
||||
|
||||
@@ -323,7 +347,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 +370,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,
|
||||
@@ -385,10 +417,18 @@ namespace ptr_container_detail
|
||||
: base_type( r )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_set_adapter( std::auto_ptr<PtrContainer> clone )
|
||||
: base_type( clone )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_set_adapter( std::unique_ptr<PtrContainer> clone )
|
||||
: base_type( std::move( clone ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
template< class U, class Set, class CA, bool b >
|
||||
ptr_set_adapter& operator=( const ptr_set_adapter<U,Set,CA,b>& r )
|
||||
@@ -397,17 +437,26 @@ namespace ptr_container_detail
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class T >
|
||||
void operator=( std::auto_ptr<T> r )
|
||||
void operator=( std::auto_ptr<T> r )
|
||||
{
|
||||
base_type::operator=( r );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class T >
|
||||
void operator=( std::unique_ptr<T> r )
|
||||
{
|
||||
base_type::operator=( std::move( r ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
std::pair<iterator,bool> insert( key_type* x ) // strong
|
||||
{
|
||||
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 )
|
||||
@@ -415,18 +464,27 @@ namespace ptr_container_detail
|
||||
return std::make_pair( iterator( res.first ), res.second );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
std::pair<iterator,bool> insert( std::auto_ptr<U> x )
|
||||
{
|
||||
return insert( x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
std::pair<iterator,bool> insert( std::unique_ptr<U> x )
|
||||
{
|
||||
return insert( x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
iterator insert( iterator where, key_type* x ) // strong
|
||||
{
|
||||
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 )
|
||||
@@ -434,11 +492,20 @@ namespace ptr_container_detail
|
||||
return iterator( res);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator where, std::auto_ptr<U> x )
|
||||
{
|
||||
return insert( where, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator where, std::unique_ptr<U> x )
|
||||
{
|
||||
return insert( where, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< typename InputIterator >
|
||||
void insert( InputIterator first, InputIterator last ) // basic
|
||||
@@ -530,7 +597,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;
|
||||
}
|
||||
}
|
||||
@@ -585,10 +652,18 @@ namespace ptr_container_detail
|
||||
: base_type( r )
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_multiset_adapter( std::auto_ptr<PtrContainer> clone )
|
||||
: base_type( clone )
|
||||
{ }
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class PtrContainer >
|
||||
explicit ptr_multiset_adapter( std::unique_ptr<PtrContainer> clone )
|
||||
: base_type( std::move( clone ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
template< class U, class Set, class CA, bool b >
|
||||
ptr_multiset_adapter& operator=( const ptr_multiset_adapter<U,Set,CA,b>& r )
|
||||
@@ -597,39 +672,66 @@ namespace ptr_container_detail
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class T >
|
||||
void operator=( std::auto_ptr<T> r )
|
||||
{
|
||||
base_type::operator=( r );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class T >
|
||||
void operator=( std::unique_ptr<T> r )
|
||||
{
|
||||
base_type::operator=( std::move( r ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
iterator insert( iterator before, key_type* x ) // strong
|
||||
{
|
||||
return base_type::insert( before, x );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, std::auto_ptr<U> x )
|
||||
{
|
||||
return insert( before, x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( iterator before, std::unique_ptr<U> x )
|
||||
{
|
||||
return insert( before, x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
iterator insert( key_type* x ) // strong
|
||||
{
|
||||
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();
|
||||
return iterator( res );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
template< class U >
|
||||
iterator insert( std::auto_ptr<U> x )
|
||||
{
|
||||
return insert( x.release() );
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
||||
template< class U >
|
||||
iterator insert( std::unique_ptr<U> x )
|
||||
{
|
||||
return insert( x.release() );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< typename InputIterator >
|
||||
void insert( InputIterator first, InputIterator last ) // basic
|
||||
@@ -689,4 +791,8 @@ namespace ptr_container_detail
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/ptr_container/ptr_map_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -29,13 +35,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;
|
||||
|
||||
@@ -245,4 +254,8 @@ namespace boost
|
||||
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,14 @@
|
||||
|
||||
#include <boost/ptr_container/indirect_fun.hpp>
|
||||
#include <boost/ptr_container/ptr_set_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@@ -29,16 +35,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;
|
||||
@@ -237,4 +245,8 @@ namespace boost
|
||||
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
#include <vector>
|
||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||
#include <boost/ptr_container/detail/ptr_container_disable_deprecated.hpp>
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -26,15 +32,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;
|
||||
|
||||
@@ -74,4 +80,8 @@ namespace boost
|
||||
|
||||
}
|
||||
|
||||
#if defined(BOOST_PTR_CONTAINER_DISABLE_DEPRECATED)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user