update boost on linux
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user