Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
#define BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
#include <boost/assert.hpp>
#include <boost/checked_delete.hpp>
#include <typeinfo>
namespace boost
{
/////////////////////////////////////////////////////////////////////////
// Clonable concept
/////////////////////////////////////////////////////////////////////////
template< class T >
inline T* new_clone( const T& r )
{
//
// @remark: if you get a compile-error here,
// it is most likely because you did not
// define new_clone( const T& ) in the namespace
// of T.
//
T* res = new T( r );
BOOST_ASSERT( typeid(r) == typeid(*res) &&
"Default new_clone() sliced object!" );
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 )
{
checked_delete( r );
}
/////////////////////////////////////////////////////////////////////////
// CloneAllocator concept
/////////////////////////////////////////////////////////////////////////
struct heap_clone_allocator
{
template< class U >
static U* allocate_clone( const U& r )
{
return new_clone( r );
}
template< class U >
static void deallocate_clone( const U* r )
{
delete_clone( r );
}
};
struct view_clone_allocator
{
template< class U >
static U* allocate_clone( const U& r )
{
return const_cast<U*>(&r);
}
template< class U >
static void deallocate_clone( const U* /*r*/ )
{
// do nothing
}
};
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,411 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_ASSOCIATIVE_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_ASSOCIATIVE_PTR_CONTAINER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class Config,
class CloneAllocator
>
class associative_ptr_container :
public reversible_ptr_container<Config,CloneAllocator>
{
typedef reversible_ptr_container<Config,CloneAllocator>
base_type;
typedef BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
scoped_deleter;
typedef BOOST_DEDUCED_TYPENAME Config::container_type
container_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME Config::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME Config::key_compare
key_compare;
typedef BOOST_DEDUCED_TYPENAME Config::value_compare
value_compare;
typedef BOOST_DEDUCED_TYPENAME Config::hasher
hasher;
typedef BOOST_DEDUCED_TYPENAME Config::key_equal
key_equal;
typedef BOOST_DEDUCED_TYPENAME Config::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME Config::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME Config::local_iterator
local_iterator;
typedef BOOST_DEDUCED_TYPENAME Config::const_local_iterator
const_local_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::reference
reference;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
public: // foundation
associative_ptr_container()
{ }
template< class SizeType >
associative_ptr_container( SizeType n, unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Compare, class Allocator >
associative_ptr_container( const Compare& comp,
const Allocator& a )
: base_type( comp, a, container_type() )
{ }
template< class Hash, class Pred, class Allocator >
associative_ptr_container( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator, class Compare, class Allocator >
associative_ptr_container( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a )
: base_type( first, last, comp, a, container_type() )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
associative_ptr_container( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class PtrContainer >
explicit associative_ptr_container( std::auto_ptr<PtrContainer> r )
: base_type( r )
{ }
associative_ptr_container( const associative_ptr_container& r )
: base_type( r.begin(), r.end(), container_type() )
{ }
template< class C, class V >
associative_ptr_container( const associative_ptr_container<C,V>& r )
: base_type( r.begin(), r.end(), container_type() )
{ }
template< class PtrContainer >
associative_ptr_container& operator=( std::auto_ptr<PtrContainer> r ) // nothrow
{
base_type::operator=( r );
return *this;
}
associative_ptr_container& operator=( associative_ptr_container r ) // strong
{
this->swap( r );
return *this;
}
public: // associative container interface
key_compare key_comp() const
{
return this->base().key_comp();
}
value_compare value_comp() const
{
return this->base().value_comp();
}
iterator erase( iterator before ) // nothrow
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( before != this->end() );
this->remove( before ); // nothrow
iterator res( before ); // nothrow
++res; // nothrow
this->base().erase( before.base() ); // nothrow
return res; // nothrow
}
size_type erase( const key_type& x ) // nothrow
{
iterator i( this->base().find( x ) );
// nothrow
if( i == this->end() ) // nothrow
return 0u; // nothrow
this->remove( i ); // nothrow
return this->base().erase( x ); // nothrow
}
iterator erase( iterator first,
iterator last ) // nothrow
{
iterator res( last ); // nothrow
if( res != this->end() )
++res; // nothrow
this->remove( first, last ); // nothrow
this->base().erase( first.base(), last.base() ); // nothrow
return res; // nothrow
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_convertible<Range&,key_type&>,
iterator >::type
erase( const Range& r )
{
return erase( boost::begin(r), boost::end(r) );
}
#endif
protected:
template< class AssociatePtrCont >
void multi_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator object,
AssociatePtrCont& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
this->base().insert( *object.base() ); // strong
from.base().erase( object.base() ); // nothrow
}
template< class AssociatePtrCont >
size_type multi_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator first,
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator last,
AssociatePtrCont& from ) // basic
{
BOOST_ASSERT( (void*)&from != (void*)this );
size_type res = 0;
for( ; first != last; )
{
BOOST_ASSERT( first != from.end() );
this->base().insert( *first.base() ); // strong
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator
to_delete( first );
++first;
from.base().erase( to_delete.base() ); // nothrow
++res;
}
return res;
}
template< class AssociatePtrCont >
bool single_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator object,
AssociatePtrCont& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> p =
this->base().insert( *object.base() ); // strong
if( p.second )
from.base().erase( object.base() ); // nothrow
return p.second;
}
template< class AssociatePtrCont >
size_type single_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator first,
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator last,
AssociatePtrCont& from ) // basic
{
BOOST_ASSERT( (void*)&from != (void*)this );
size_type res = 0;
for( ; first != last; )
{
BOOST_ASSERT( first != from.end() );
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> p =
this->base().insert( *first.base() ); // strong
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator
to_delete( first );
++first;
if( p.second )
{
from.base().erase( to_delete.base() ); // nothrow
++res;
}
}
return res;
}
reference front()
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( *this->begin().base() != 0 );
return *this->begin();
}
const_reference front() const
{
return const_cast<associative_ptr_container*>(this)->front();
}
reference back()
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( *(--this->end()).base() != 0 );
return *--this->end();
}
const_reference back() const
{
return const_cast<associative_ptr_container*>(this)->back();
}
protected: // unordered interface
hasher hash_function() const
{
return this->base().hash_function();
}
key_equal key_eq() const
{
return this->base().key_eq();
}
size_type bucket_count() const
{
return this->base().bucket_count();
}
size_type max_bucket_count() const
{
return this->base().max_bucket_count();
}
size_type bucket_size( size_type n ) const
{
return this->base().bucket_size( n );
}
float load_factor() const
{
return this->base().load_factor();
}
float max_load_factor() const
{
return this->base().max_load_factor();
}
void max_load_factor( float factor )
{
return this->base().max_load_factor( factor );
}
void rehash( size_type n )
{
this->base().rehash( n );
}
public:
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(70190006))
iterator begin()
{
return base_type::begin();
}
const_iterator begin() const
{
return base_type::begin();
}
iterator end()
{
return base_type::end();
}
const_iterator end() const
{
return base_type::end();
}
const_iterator cbegin() const
{
return base_type::cbegin();
}
const_iterator cend() const
{
return base_type::cend();
}
#else
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
#endif
protected:
local_iterator begin( size_type n )
{
return local_iterator( this->base().begin( n ) );
}
const_local_iterator begin( size_type n ) const
{
return const_local_iterator( this->base().begin( n ) );
}
local_iterator end( size_type n )
{
return local_iterator( this->base().end( n ) );
}
const_local_iterator end( size_type n ) const
{
return const_local_iterator( this->base().end( n ) );
}
const_local_iterator cbegin( size_type n ) const
{
return const_local_iterator( this->base().cbegin( n ) );
}
const_local_iterator cend( size_type n )
{
return const_local_iterator( this->base().cend( n ) );
}
}; // class 'associative_ptr_container'
} // namespace 'ptr_container_detail'
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,69 @@
// (C) Copyright Jonathan Turkanis 2004-2005.
// 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.)
// Contains the definition of move_ptrs::default_deleter, the default
// Deleter template argument to move_ptr. Uses a technique of Daniel
// Wallin to capture the type of a pointer at the time the deleter
// is constructed, so that move_ptrs can delete objects of incomplete
// type by default.
#ifndef BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED
#define BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED
#include <boost/checked_delete.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/remove_bounds.hpp>
namespace boost { namespace ptr_container_detail { namespace move_ptrs {
namespace ptr_container_detail {
template<typename T>
struct deleter_base {
typedef void (*deleter)(T*);
deleter_base(deleter d) { delete_ = d; }
void operator() (T* t) const { delete_(t); }
static deleter delete_;
};
template<class T>
typename deleter_base<T>::deleter
deleter_base<T>::delete_;
template<typename T>
struct scalar_deleter : deleter_base<T> {
typedef deleter_base<T> base;
scalar_deleter() : base(do_delete) { }
static void do_delete(T* t) { checked_delete(t); }
};
template<typename T>
struct array_deleter
: deleter_base<typename remove_bounds<T>::type>
{
typedef typename remove_bounds<T>::type element_type;
typedef deleter_base<element_type> base;
array_deleter() : base(do_delete) { }
static void do_delete(element_type* t) { checked_array_delete(t); }
};
} // End namespace ptr_container_detail.
template<typename T>
struct default_deleter
: mpl::if_<
is_array<T>,
ptr_container_detail::array_deleter<T>,
ptr_container_detail::scalar_deleter<T>
>::type
{
default_deleter() { }
template<typename TT>
default_deleter(default_deleter<TT> tt) { }
};
} } } // End namespaces ptr_container_detail, move_ptrs, boost.
#endif // #ifndef BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED

View File

@@ -0,0 +1,73 @@
// (C) Copyright Thorsten Ottosen 2005
// (C) Copyright Howard Hinnant 2004
// (C) Copyright Jonathan Turkanis 2004
// 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.)
//
// Contains type traits machinery for incomplete arrays. MPL compatibility
// is included for completeness, but is not necessary for the current
// application.
//
#ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
#define BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
#include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_bounds.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace ptr_container_detail { namespace move_ptrs {
// From Howard Hinnant.
template<typename T, typename U>
struct is_array_convertible {
typedef typename remove_bounds<T>::type t_element;
typedef typename remove_bounds<U>::type u_element;
typedef typename remove_cv<t_element>::type t_base;
typedef typename remove_cv<u_element>::type u_base;
typedef typename
mpl::and_<
is_array<T>,
is_array<U>,
is_same<t_base, u_base>,
is_convertible<t_element*, u_element*>
>::type type;
BOOST_STATIC_CONSTANT(bool, value = type::value);
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, is_array_convertible, (T, U))
};
template<typename T, typename U>
struct is_smart_ptr_convertible
: mpl::if_<
is_array<T>,
is_array_convertible<T, U>,
is_convertible<T*, U*>
>::type
{ };
#ifndef BOOST_NO_SFINAE
template<typename Src, typename Tgt, typename T = void>
struct enable_if_convertible
: enable_if<
is_smart_ptr_convertible<Src, Tgt>,
T
>
{ };
#else
template<typename Src, typename Tgt, class T >
struct enable_if_convertible : mpl::identity<T> { };
#endif
} } } // End namespaces ptr_container_detail, move_ptrs, boost.
#endif // #ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED

View File

@@ -0,0 +1,132 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_MAP_ITERATOR_HPP
#define BOOST_PTR_CONTAINER_MAP_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility/compare_pointees.hpp>
#include <utility>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable:4512) // Assignment operator could not be generated.
#endif
namespace boost
{
namespace ptr_container_detail
{
template< class F, class S >
struct ref_pair
{
typedef F first_type;
typedef S second_type;
const F& first;
S second;
template< class F2, class S2 >
ref_pair( const std::pair<F2,S2>& p )
: first(p.first), second(static_cast<S>(p.second))
{ }
template< class RP >
ref_pair( const RP* rp )
: first(rp->first), second(rp->second)
{ }
const ref_pair* const operator->() const
{
return this;
}
friend inline bool operator==( ref_pair l, ref_pair r )
{
return l.first == r.first &&
boost::equal_pointees( l.second, r.second );
}
friend inline bool operator!=( ref_pair l, ref_pair r )
{
return !( l == r );
}
friend inline bool operator<( ref_pair l, ref_pair r )
{
if( l.first == r.first )
return boost::less_pointees( l.second, r.second );
else
return l.first < r.first;
}
friend inline bool operator>( ref_pair l, ref_pair r )
{
return r < l;
}
friend inline bool operator<=( ref_pair l, ref_pair r )
{
return !(r < l);
}
friend inline bool operator>=( ref_pair l, ref_pair r )
{
return !(l < r);
}
};
}
template<
class I, // base iterator
class F, // first type, key type
class S // second type, mapped type
>
class ptr_map_iterator :
public boost::iterator_adaptor< ptr_map_iterator<I,F,S>, I,
ptr_container_detail::ref_pair<F,S>,
use_default,
ptr_container_detail::ref_pair<F,S> >
{
typedef boost::iterator_adaptor< ptr_map_iterator<I,F,S>, I,
ptr_container_detail::ref_pair<F,S>,
use_default,
ptr_container_detail::ref_pair<F,S> >
base_type;
public:
ptr_map_iterator() : base_type()
{ }
explicit ptr_map_iterator( const I& i ) : base_type(i)
{ }
template< class I2, class F2, class S2 >
ptr_map_iterator( const ptr_map_iterator<I2,F2,S2>& r )
: base_type(r.base())
{ }
}; // class 'ptr_map_iterator'
}
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#endif

View File

@@ -0,0 +1,66 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_META_FUNCTIONS
#define BOOST_PTR_CONTAINER_DETAIL_META_FUNCTIONS
#include <boost/mpl/identity.hpp>
#include <boost/mpl/eval_if.hpp>
namespace boost
{
namespace ptr_container_detail
{
template< class T >
struct select_value_compare
{
typedef typename T::value_compare type;
};
template< class T >
struct select_key_compare
{
typedef typename T::key_compare type;
};
template< class T >
struct select_hasher
{
typedef typename T::hasher type;
};
template< class T >
struct select_key_equal
{
typedef typename T::key_equal type;
};
template< class T >
struct select_iterator
{
typedef typename T::iterator type;
};
template< class T >
struct select_local_iterator
{
typedef typename T::local_iterator type;
};
template< class T >
struct select_const_local_iterator
{
typedef typename T::const_local_iterator type;
};
}
}
#endif

View File

@@ -0,0 +1,44 @@
// (C) Copyright Daniel Wallin 2004.
// 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.)
// Contains the definitions of the class template move_source and the function
// template move, which together make move pointers moveable.
#ifndef BOOST_MOVE_HPP_INCLUDED
#define BOOST_MOVE_HPP_INCLUDED
namespace boost { namespace ptr_container_detail {
namespace move_ptrs {
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512)
#endif
template<typename Ptr>
class move_source {
public:
move_source(Ptr& ptr) : ptr_(ptr) {}
Ptr& ptr() const { return ptr_; }
private:
Ptr& ptr_;
move_source(const Ptr&);
};
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
} // End namespace move_ptrs.
template<typename T>
move_ptrs::move_source<T> move(T& x)
{ return move_ptrs::move_source<T>(x); }
} // namespace 'ptr_container_detail'
} // End namespace boost.
#endif // #ifndef BOOST_MOVE_HPP_INCLUDED

View File

@@ -0,0 +1,752 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_REVERSIBLE_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_REVERSIBLE_PTR_CONTAINER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#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/exception.hpp>
#include <boost/ptr_container/clone_allocator.hpp>
#include <boost/ptr_container/nullable.hpp>
#ifdef BOOST_NO_SFINAE
#else
#include <boost/range/functions.hpp>
#endif
#include <boost/config.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/range/iterator.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <typeinfo>
#include <memory>
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4127)
#endif
namespace boost
{
namespace ptr_container_detail
{
template< class CloneAllocator >
struct clone_deleter
{
template< class T >
void operator()( const T* p ) const
{
CloneAllocator::deallocate_clone( p );
}
};
template< class T >
struct is_pointer_or_integral
{
BOOST_STATIC_CONSTANT(bool, value = is_pointer<T>::value || is_integral<T>::value );
};
struct is_pointer_or_integral_tag {};
struct is_range_tag {};
struct sequence_tag {};
struct fixed_length_sequence_tag : sequence_tag {};
struct associative_container_tag {};
struct ordered_associative_container_tag : associative_container_tag {};
struct unordered_associative_container_tag : associative_container_tag {};
template
<
class Config,
class CloneAllocator
>
class reversible_ptr_container
{
private:
BOOST_STATIC_CONSTANT( bool, allow_null = Config::allow_null );
typedef BOOST_DEDUCED_TYPENAME Config::value_type Ty_;
template< bool allow_null_values >
struct null_clone_allocator
{
template< class Iter >
static Ty_* allocate_clone_from_iterator( Iter i )
{
return allocate_clone( Config::get_const_pointer( i ) );
}
static Ty_* allocate_clone( const Ty_* x )
{
if( allow_null_values )
{
if( x == 0 )
return 0;
}
else
{
BOOST_ASSERT( x != 0 && "Cannot insert clone of null!" );
}
Ty_* res = CloneAllocator::allocate_clone( *x );
BOOST_ASSERT( typeid(*res) == typeid(*x) &&
"CloneAllocator::allocate_clone() does not clone the "
"object properly. Check that new_clone() is implemented"
" correctly" );
return res;
}
static void deallocate_clone( const Ty_* x )
{
if( allow_null_values )
{
if( x == 0 )
return;
}
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_;
public:
Cont& base() { return c_; }
protected: // having this public could break encapsulation
const Cont& base() const { return c_; }
public: // typedefs
typedef Ty_* value_type;
typedef Ty_* pointer;
typedef Ty_& reference;
typedef const Ty_& const_reference;
typedef BOOST_DEDUCED_TYPENAME Config::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME Config::const_iterator
const_iterator;
typedef boost::reverse_iterator< iterator >
reverse_iterator;
typedef boost::reverse_iterator< const_iterator >
const_reverse_iterator;
typedef BOOST_DEDUCED_TYPENAME Cont::difference_type
difference_type;
typedef BOOST_DEDUCED_TYPENAME Cont::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>
auto_type;
protected:
typedef ptr_container_detail::scoped_deleter<Ty_,null_cloner_type>
scoped_deleter;
typedef BOOST_DEDUCED_TYPENAME Cont::iterator
ptr_iterator;
typedef BOOST_DEDUCED_TYPENAME Cont::const_iterator
ptr_const_iterator;
private:
template< class InputIterator >
void copy( InputIterator first, InputIterator last )
{
std::copy( first, last, begin() );
}
void copy( const reversible_ptr_container& r )
{
copy( r.begin(), r.end() );
}
void copy_clones_and_release( scoped_deleter& sd ) // nothrow
{
BOOST_ASSERT( size_type( std::distance( sd.begin(), sd.end() ) ) == c_.size() );
std::copy( sd.begin(), sd.end(), c_.begin() );
sd.release();
}
template< class ForwardIterator >
void clone_assign( ForwardIterator first,
ForwardIterator last ) // strong
{
BOOST_ASSERT( first != last );
scoped_deleter sd( first, last ); // strong
copy_clones_and_release( sd ); // nothrow
}
template< class ForwardIterator >
void clone_back_insert( ForwardIterator first,
ForwardIterator last )
{
BOOST_ASSERT( first != last );
scoped_deleter sd( first, last );
insert_clones_and_release( sd, end() );
}
void remove_all()
{
remove( begin(), end() );
}
protected:
void insert_clones_and_release( scoped_deleter& sd,
iterator where ) // strong
{
//
// 'c_.insert' always provides the strong guarantee for T* elements
// since a copy constructor of a pointer cannot throw
//
c_.insert( where.base(),
sd.begin(), sd.end() );
sd.release();
}
void insert_clones_and_release( scoped_deleter& sd ) // strong
{
c_.insert( sd.begin(), sd.end() );
sd.release();
}
template< class U >
void remove( U* ptr )
{
null_policy_deallocate_clone( ptr );
}
template< class I >
void remove( I i )
{
null_policy_deallocate_clone( Config::get_const_pointer(i) );
}
template< class I >
void remove( I first, I last )
{
for( ; first != last; ++first )
remove( first );
}
static void enforce_null_policy( const Ty_* x, const char* msg )
{
if( !allow_null )
{
BOOST_PTR_CONTAINER_THROW_EXCEPTION( 0 == x && "null not allowed",
bad_pointer, msg );
}
}
static Ty_* null_policy_allocate_clone( const Ty_* x )
{
return null_cloner_type::allocate_clone( x );
}
static void null_policy_deallocate_clone( const Ty_* x )
{
null_cloner_type::deallocate_clone( x );
}
private:
template< class ForwardIterator >
ForwardIterator advance( ForwardIterator begin, size_type n )
{
ForwardIterator iter = begin;
std::advance( iter, n );
return iter;
}
template< class I >
void constructor_impl( I first, I last, std::input_iterator_tag ) // basic
{
while( first != last )
{
insert( end(), null_cloner_type::allocate_clone_from_iterator(first) );
++first;
}
}
template< class I >
void constructor_impl( I first, I last, std::forward_iterator_tag ) // strong
{
if( first == last )
return;
clone_back_insert( first, last );
}
template< class I >
void associative_constructor_impl( I first, I last ) // strong
{
if( first == last )
return;
scoped_deleter sd( first, last );
insert_clones_and_release( sd );
}
public: // foundation! should be protected!
reversible_ptr_container()
{ }
template< class SizeType >
reversible_ptr_container( SizeType n, unordered_associative_container_tag )
: c_( n )
{ }
template< class SizeType >
reversible_ptr_container( SizeType n, fixed_length_sequence_tag )
: c_( n )
{ }
template< class SizeType >
reversible_ptr_container( SizeType n, const allocator_type& a,
fixed_length_sequence_tag )
: c_( n, a )
{ }
explicit reversible_ptr_container( const allocator_type& a )
: c_( a )
{ }
template< class PtrContainer >
explicit reversible_ptr_container( std::auto_ptr<PtrContainer> clone )
{
swap( *clone );
}
reversible_ptr_container( const reversible_ptr_container& r )
{
constructor_impl( r.begin(), r.end(), std::forward_iterator_tag() );
}
template< class C, class V >
reversible_ptr_container( const reversible_ptr_container<C,V>& r )
{
constructor_impl( r.begin(), r.end(), std::forward_iterator_tag() );
}
template< class PtrContainer >
reversible_ptr_container& operator=( std::auto_ptr<PtrContainer> clone ) // nothrow
{
swap( *clone );
return *this;
}
reversible_ptr_container& operator=( reversible_ptr_container r ) // strong
{
swap( r );
return *this;
}
// overhead: null-initilization of container pointer (very cheap compared to cloning)
// overhead: 1 heap allocation (very cheap compared to cloning)
template< class InputIterator >
reversible_ptr_container( InputIterator first,
InputIterator last,
const allocator_type& a = allocator_type() ) // basic, strong
: c_( a )
{
constructor_impl( first, last,
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#else
BOOST_DEDUCED_TYPENAME
#endif
iterator_category<InputIterator>::type() );
}
template< class Compare >
reversible_ptr_container( const Compare& comp,
const allocator_type& a )
: c_( comp, a ) {}
template< class ForwardIterator >
reversible_ptr_container( ForwardIterator first,
ForwardIterator last,
fixed_length_sequence_tag )
: c_( std::distance(first,last) )
{
constructor_impl( first, last,
std::forward_iterator_tag() );
}
template< class SizeType, class InputIterator >
reversible_ptr_container( SizeType n,
InputIterator first,
InputIterator last,
fixed_length_sequence_tag )
: c_( n )
{
constructor_impl( first, last,
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#else
BOOST_DEDUCED_TYPENAME
#endif
iterator_category<InputIterator>::type() );
}
template< class Compare >
reversible_ptr_container( const Compare& comp,
const allocator_type& a,
associative_container_tag )
: c_( comp, a )
{ }
template< class InputIterator >
reversible_ptr_container( InputIterator first,
InputIterator last,
associative_container_tag )
{
associative_constructor_impl( first, last );
}
template< class InputIterator, class Compare >
reversible_ptr_container( InputIterator first,
InputIterator last,
const Compare& comp,
const allocator_type& a,
associative_container_tag )
: c_( comp, a )
{
associative_constructor_impl( first, last );
}
explicit reversible_ptr_container( size_type n )
: c_( n ) {}
template< class Hash, class Pred >
reversible_ptr_container( const Hash& h,
const Pred& pred,
const allocator_type& a )
: c_( h, pred, a ) {}
template< class InputIterator, class Hash, class Pred >
reversible_ptr_container( InputIterator first,
InputIterator last,
const Hash& h,
const Pred& pred,
const allocator_type& a )
: c_( h, pred, a )
{
associative_constructor_impl( first, last );
}
public:
~reversible_ptr_container()
{
remove_all();
}
public:
allocator_type get_allocator() const
{
return c_.get_allocator();
}
public: // container requirements
iterator begin()
{ return iterator( c_.begin() ); }
const_iterator begin() const
{ return const_iterator( c_.begin() ); }
iterator end()
{ return iterator( c_.end() ); }
const_iterator end() const
{ return const_iterator( c_.end() ); }
reverse_iterator rbegin()
{ return reverse_iterator( this->end() ); }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator( this->end() ); }
reverse_iterator rend()
{ return reverse_iterator( this->begin() ); }
const_reverse_iterator rend() const
{ return const_reverse_iterator( this->begin() ); }
const_iterator cbegin() const
{ return const_iterator( c_.begin() ); }
const_iterator cend() const
{ return const_iterator( c_.end() ); }
const_reverse_iterator crbegin() const
{ return const_reverse_iterator( this->end() ); }
const_reverse_iterator crend() const
{ return const_reverse_iterator( this->begin() ); }
void swap( reversible_ptr_container& r ) // nothrow
{
c_.swap( r.c_ );
}
size_type size() const // nothrow
{
return c_.size();
}
size_type max_size() const // nothrow
{
return c_.max_size();
}
bool empty() const // nothrow
{
return c_.empty();
}
public: // optional container requirements
bool operator==( const reversible_ptr_container& r ) const // nothrow
{
if( size() != r.size() )
return false;
else
return std::equal( begin(), end(), r.begin() );
}
bool operator!=( const reversible_ptr_container& r ) const // nothrow
{
return !(*this == r);
}
bool operator<( const reversible_ptr_container& r ) const // nothrow
{
return std::lexicographical_compare( begin(), end(), r.begin(), r.end() );
}
bool operator<=( const reversible_ptr_container& r ) const // nothrow
{
return !(r < *this);
}
bool operator>( const reversible_ptr_container& r ) const // nothrow
{
return r < *this;
}
bool operator>=( const reversible_ptr_container& r ) const // nothrow
{
return !(*this < r);
}
public: // modifiers
iterator insert( iterator before, Ty_* x )
{
enforce_null_policy( x, "Null pointer in 'insert()'" );
auto_type ptr( x ); // nothrow
iterator res( c_.insert( before.base(), x ) ); // strong, commit
ptr.release(); // nothrow
return res;
}
template< class U >
iterator insert( iterator before, std::auto_ptr<U> x )
{
return insert( before, x.release() );
}
iterator erase( iterator x ) // nothrow
{
BOOST_ASSERT( !empty() );
BOOST_ASSERT( x != end() );
remove( x );
return iterator( c_.erase( x.base() ) );
}
iterator erase( iterator first, iterator last ) // nothrow
{
remove( first, last );
return iterator( c_.erase( first.base(),
last.base() ) );
}
template< class Range >
iterator erase( const Range& r )
{
return erase( boost::begin(r), boost::end(r) );
}
void clear()
{
remove_all();
c_.clear();
}
public: // access interface
auto_type release( iterator where )
{
BOOST_ASSERT( where != end() );
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
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()'" );
auto_type ptr( x );
BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation,
"'replace()' on empty container" );
auto_type old( Config::get_pointer( where ) ); // nothrow
const_cast<void*&>(*where.base()) = ptr.release();
return boost::ptr_container_detail::move( old );
}
template< class U >
auto_type replace( iterator where, std::auto_ptr<U> x )
{
return replace( where, x.release() );
}
auto_type replace( size_type idx, Ty_* x ) // strong
{
enforce_null_policy( x, "Null pointer in 'replace()'" );
auto_type ptr( x );
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
return boost::ptr_container_detail::move( old );
}
template< class U >
auto_type replace( size_type idx, std::auto_ptr<U> x )
{
return replace( idx, x.release() );
}
}; // 'reversible_ptr_container'
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \
typename base_type::auto_type \
release( typename base_type::iterator i ) \
{ \
return boost::ptr_container_detail::move(base_type::release(i)); \
}
#else
#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 ) \
explicit PC( std::auto_ptr<this_type> r ) \
: base_type ( r ) { } \
\
PC& operator=( std::auto_ptr<this_type> r ) \
{ \
base_type::operator=( r ); \
return *this; \
} \
\
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() ) ); \
}
#define BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type ) \
\
template< class U > \
PC( const PC<U>& r ) : base_type( r ) { } \
\
PC& operator=( PC r ) \
{ \
this->swap( r ); \
return *this; \
} \
#define BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS( PC, base_type ) \
typedef BOOST_DEDUCED_TYPENAME base_type::iterator iterator; \
typedef BOOST_DEDUCED_TYPENAME base_type::size_type size_type; \
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference const_reference; \
typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type allocator_type; \
PC() {} \
explicit PC( const allocator_type& a ) : base_type(a) {} \
template< class InputIterator > \
PC( InputIterator first, InputIterator last ) : base_type( first, last ) {} \
template< class InputIterator > \
PC( InputIterator first, InputIterator last, \
const allocator_type& a ) : base_type( first, last, a ) {}
#define BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( PC, base_type, this_type ) \
BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS( PC, base_type ) \
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type )
#define BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( PC, base_type, this_type ) \
BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( PC, base_type, this_type ) \
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type )
} // namespace 'ptr_container_detail'
//
// @remark: expose movability of internal move-pointer
//
namespace ptr_container
{
using ptr_container_detail::move;
}
} // namespace 'boost'
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
#endif

View File

@@ -0,0 +1,121 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SCOPED_DELETER_HPP
#define BOOST_PTR_CONTAINER_SCOPED_DELETER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <iterator>
#include <cstddef>
#include <boost/scoped_array.hpp>
namespace boost
{
namespace ptr_container_detail
{
template< class T, class CloneAllocator >
class scoped_deleter
{
typedef std::size_t size_type;
scoped_array<T*> ptrs_;
size_type stored_;
bool released_;
public:
scoped_deleter( T** a, size_type size )
: ptrs_( a ), stored_( size ), released_( false )
{
BOOST_ASSERT( a );
}
scoped_deleter( size_type size )
: 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),
released_( false )
{
for( size_type i = 0; i != n; i++ )
add( CloneAllocator::allocate_clone( &x ) );
BOOST_ASSERT( stored_ > 0 );
}
template< class InputIterator >
scoped_deleter ( InputIterator first, InputIterator last ) // strong
: ptrs_( new T*[ std::distance(first,last) ] ),
stored_(0),
released_( false )
{
for( ; first != last; ++first )
add( CloneAllocator::allocate_clone_from_iterator( first ) );
BOOST_ASSERT( stored_ > 0 );
}
~scoped_deleter()
{
if ( !released_ )
{
for( size_type i = 0u; i != stored_; ++i )
CloneAllocator::deallocate_clone( ptrs_[i] );
}
}
void add( T* t )
{
BOOST_ASSERT( ptrs_.get() != 0 );
ptrs_[stored_] = t;
++stored_;
}
void release()
{
released_ = true;
}
T** begin()
{
BOOST_ASSERT( ptrs_.get() != 0 );
return &ptrs_[0];
}
T** end()
{
BOOST_ASSERT( ptrs_.get() != 0 );
return &ptrs_[stored_];
}
}; // class 'scoped_deleter'
}
}
#endif

View File

@@ -0,0 +1,87 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_PTR_MAP_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_PTR_MAP_ADAPTER_HPP
#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>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
void save(Archive& ar, const ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
{
typedef ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator,Ordered> container;
typedef BOOST_DEDUCED_TYPENAME container::const_iterator const_iterator;
ar << boost::serialization::make_nvp( ptr_container_detail::count(),
ptr_container_detail::serialize_as_const(c.size()) );
const_iterator i = c.begin(), e = c.end();
for(; i != e; ++i)
{
ar << boost::serialization::make_nvp( ptr_container_detail::first(), i->first );
ar << boost::serialization::make_nvp( ptr_container_detail::second(),
ptr_container_detail::serialize_as_const(i->second) );
}
}
template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
void load(Archive& ar, ptr_map_adapter<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
{
typedef ptr_map_adapter<T, VoidPtrMap, CloneAllocator,Ordered> container;
typedef BOOST_DEDUCED_TYPENAME container::key_type key_type;
typedef BOOST_DEDUCED_TYPENAME container::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME container::iterator iterator;
c.clear();
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
for(size_type i = 0u; i != n; ++i)
{
key_type key;
T* value;
ar >> boost::serialization::make_nvp( ptr_container_detail::first(), key );
ar >> boost::serialization::make_nvp( ptr_container_detail::second(), value );
std::pair<iterator, bool> p = c.insert(key, value);
ar.reset_object_address(&p.first->first, &key);
}
}
template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
void load(Archive& ar, ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
{
typedef ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator,Ordered> container;
typedef BOOST_DEDUCED_TYPENAME container::key_type key_type;
typedef BOOST_DEDUCED_TYPENAME container::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME container::iterator iterator;
c.clear();
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
for(size_type i = 0u; i != n; ++i)
{
key_type key;
T* value;
ar >> boost::serialization::make_nvp( ptr_container_detail::first(), key );
ar >> boost::serialization::make_nvp( ptr_container_detail::second(), value );
iterator p = c.insert(key, value);
ar.reset_object_address(&p->first, &key);
}
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,86 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_REVERSIBLE_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_REVERSIBLE_PTR_CONTAINER_HPP
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
#include <boost/ptr_container/detail/serialize_xml_names.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/nvp.hpp>
namespace boost
{
namespace ptr_container_detail
{
template<class Archive, class Config, class CloneAllocator>
void save_helper(Archive& ar, const ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c)
{
typedef ptr_container_detail::reversible_ptr_container<Config, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME container_type::value_type value_type;
const_iterator i = c.begin(), e = c.end();
for(; i != e; ++i)
ar << boost::serialization::make_nvp( ptr_container_detail::item(),
ptr_container_detail::serialize_as_const(static_cast<value_type>(*i.base())));
}
template<class Archive, class Config, class CloneAllocator>
void load_helper(Archive& ar, ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c,
BOOST_DEDUCED_TYPENAME ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>::size_type n)
{
typedef ptr_container_detail::reversible_ptr_container<Config, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME container_type::value_type value_type;
//
// Called after an appropriate reserve on c.
//
c.clear();
for(size_type i = 0u; i != n; ++i)
{
//
// Remark: pointers are not tracked,
// so we need not call ar.reset_object_address(v, u)
//
value_type ptr;
ar >> boost::serialization::make_nvp( ptr_container_detail::item(), ptr );
c.insert(c.end(), ptr);
}
}
} // namespace ptr_container_detail
namespace serialization
{
template<class Archive, class Config, class CloneAllocator>
void save(Archive& ar, const ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c, unsigned int /*version*/)
{
ar << boost::serialization::make_nvp( ptr_container_detail::count(),
ptr_container_detail::serialize_as_const(c.size()) );
ptr_container_detail::save_helper(ar, c);
}
template<class Archive, class Config, class CloneAllocator>
void load(Archive& ar, ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c, unsigned int /*version*/)
{
typedef ptr_container_detail::reversible_ptr_container<Config, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
ptr_container_detail::load_helper(ar, c, n);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,32 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2007. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_XML_NAMES
#define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_XML_NAMES
namespace boost
{
namespace ptr_container_detail
{
inline const char* count() { return "count"; }
inline const char* item() { return "item"; }
inline const char* first() { return "first"; }
inline const char* second() { return "second"; }
template<class T>
inline T const& serialize_as_const(T const& r)
{
return r;
}
}
}
#endif

View File

@@ -0,0 +1,211 @@
// (C) Copyright Thorsten Ottosen 2005.
// (C) Copyright Jonathan Turkanis 2004.
// (C) Copyright Daniel Wallin 2004.
// 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.)
// Implementation of the move_ptr from the "Move Proposal"
// (http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1377.htm)
// enhanced to support custom deleters and safe boolean conversions.
//
// The implementation is based on an implementation by Daniel Wallin, at
// "http://aspn.activestate.com/ASPN/Mail/Message/Attachments/boost/
// 400DC271.1060903@student.umu.se/move_ptr.hpp". The current was adapted
// by Jonathan Turkanis to incorporating ideas of Howard Hinnant and
// Rani Sharoni.
#ifndef BOOST_STATIC_MOVE_PTR_HPP_INCLUDED
#define BOOST_STATIC_MOVE_PTR_HPP_INCLUDED
#include <boost/config.hpp> // Member template friends, put size_t in std.
#include <cstddef> // size_t
#include <boost/compressed_pair.hpp>
#include <boost/ptr_container/detail/default_deleter.hpp>
#include <boost/ptr_container/detail/is_convertible.hpp>
#include <boost/ptr_container/detail/move.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_array.hpp>
#if defined(BOOST_MSVC)
#pragma warning(push)
#pragma warning(disable:4521) // Multiple copy constuctors.
#endif
namespace boost { namespace ptr_container_detail {
template< typename T,
typename Deleter =
move_ptrs::default_deleter<T> >
class static_move_ptr
{
public:
typedef typename remove_bounds<T>::type element_type;
typedef Deleter deleter_type;
private:
struct safe_bool_helper { int x; };
typedef int safe_bool_helper::* safe_bool;
typedef boost::compressed_pair<element_type*, Deleter> impl_type;
public:
typedef typename impl_type::second_reference deleter_reference;
typedef typename impl_type::second_const_reference deleter_const_reference;
// Constructors
static_move_ptr() : impl_(0) { }
static_move_ptr(const static_move_ptr& p)
: impl_(p.get(), p.get_deleter())
{
const_cast<static_move_ptr&>(p).release();
}
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
static_move_ptr( const move_ptrs::move_source<static_move_ptr<T,Deleter> >& src )
#else
static_move_ptr( const move_ptrs::move_source<static_move_ptr>& src )
#endif
: impl_(src.ptr().get(), src.ptr().get_deleter())
{
src.ptr().release();
}
template<typename TT>
explicit static_move_ptr(TT* tt)
: impl_(tt, Deleter())
{ }
// Destructor
~static_move_ptr() { if (ptr()) get_deleter()(ptr()); }
// Assignment
static_move_ptr& operator=(static_move_ptr rhs)
{
rhs.swap(*this);
return *this;
}
// Smart pointer interface
element_type* get() const { return ptr(); }
element_type& operator*()
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return *ptr();
}
const element_type& operator*() const
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return *ptr();
}
element_type* operator->()
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return ptr();
}
const element_type* operator->() const
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return ptr();
}
element_type* release()
{
element_type* result = ptr();
ptr() = 0;
return result;
}
void reset()
{
if (ptr()) get_deleter()(ptr());
ptr() = 0;
}
template<typename TT>
void reset(TT* tt)
{
static_move_ptr(tt).swap(*this);
}
template<typename TT, typename DD>
void reset(TT* tt, DD dd)
{
static_move_ptr(tt, dd).swap(*this);
}
operator safe_bool() const { return ptr() ? &safe_bool_helper::x : 0; }
void swap(static_move_ptr& p) { impl_.swap(p.impl_); }
deleter_reference get_deleter() { return impl_.second(); }
deleter_const_reference get_deleter() const { return impl_.second(); }
private:
template<typename TT, typename DD>
void check(const static_move_ptr<TT, DD>& ptr)
{
typedef move_ptrs::is_smart_ptr_convertible<TT, T> convertible;
BOOST_STATIC_ASSERT(convertible::value);
}
#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_SFINAE)
// give up on this behavior
#else
template<typename Ptr> struct cant_move_from_const;
template<typename TT, typename DD>
struct cant_move_from_const< const static_move_ptr<TT, DD> > {
typedef typename static_move_ptr<TT, DD>::error type;
};
template<typename Ptr>
static_move_ptr(Ptr&, typename cant_move_from_const<Ptr>::type = 0);
public:
static_move_ptr(static_move_ptr&);
private:
template<typename TT, typename DD>
static_move_ptr( static_move_ptr<TT, DD>&,
typename
move_ptrs::enable_if_convertible<
TT, T, static_move_ptr&
>::type::type* = 0 );
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING || BOOST_NO_SFINAE
//#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
// template<typename TT, typename DD>
// friend class static_move_ptr;
//#else
public:
//#endif
typename impl_type::first_reference
ptr() { return impl_.first(); }
typename impl_type::first_const_reference
ptr() const { return impl_.first(); }
impl_type impl_;
};
} // namespace ptr_container_detail
} // End namespace boost.
#if defined(BOOST_MSVC)
#pragma warning(pop) // #pragma warning(disable:4251)
#endif
#endif // #ifndef BOOST_STATIC_MOVE_PTR_HPP_INCLUDED

View File

@@ -0,0 +1,33 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_THROW_EXCEPTION
#define BOOST_PTR_CONTAINER_DETAIL_THROW_EXCEPTION
#include <boost/assert.hpp>
#include <boost/config.hpp>
#ifdef BOOST_NO_EXCEPTIONS
#define BOOST_PTR_CONTAINER_NO_EXCEPTIONS
#endif
#ifdef BOOST_PTR_CONTAINER_NO_EXCEPTIONS
#define BOOST_PTR_CONTAINER_THROW_EXCEPTION( If, Ex, Msg ) BOOST_ASSERT( !(If) && Msg )
#else
#define BOOST_PTR_CONTAINER_THROW_EXCEPTION( If, Ex, Msg ) if( (If) ) throw Ex ( Msg )
#endif // BOOST_PTR_CONTAINER_NO_EXCEPTIONS
#endif

View File

@@ -0,0 +1,229 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_VOID_PTR_ITERATOR_HPP
#define BOOST_PTR_CONTAINER_DETAIL_VOID_PTR_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost
{
template
<
class VoidIter,
class T
>
class void_ptr_iterator
{
public:
typedef BOOST_DEDUCED_TYPENAME boost::remove_const<T>::type
value_type;
typedef T& reference;
typedef T* pointer;
typedef BOOST_DEDUCED_TYPENAME iterator_difference<VoidIter>::type
difference_type;
typedef BOOST_DEDUCED_TYPENAME iterator_category<VoidIter>::type
iterator_category;
private:
VoidIter iter_;
public:
void_ptr_iterator() : iter_()
{ }
void_ptr_iterator( VoidIter r ) : iter_(r)
{ }
//
// Remark: passing by value breaks vc7.1
//
template< class MutableIterator, class MutableT >
void_ptr_iterator( const void_ptr_iterator<MutableIterator,MutableT>& r )
#ifdef BOOST_NO_SFINAE
: iter_( VoidIter(const_cast<void**>(&*r.base())) )
#else
: iter_(r.base())
#endif
{ }
T& operator*() const
{
return *static_cast<T*>( *iter_ );
}
T* operator->() const
{
return static_cast<T*>( *iter_ );
}
void_ptr_iterator& operator++()
{
++iter_;
return *this;
}
void_ptr_iterator operator++(int)
{
void_ptr_iterator res = *this;
++iter_;
return res;
}
void_ptr_iterator& operator--()
{
--iter_;
return *this;
}
void_ptr_iterator operator--(int)
{
void_ptr_iterator res = *this;
--iter_;
return res;
}
void_ptr_iterator& operator+=( difference_type n )
{
iter_ += n;
return *this;
}
void_ptr_iterator& operator-=( difference_type n )
{
iter_ -= n;
return *this;
}
T& operator[]( difference_type n ) const
{
return *static_cast<T*>( *(iter_ + n) );
}
VoidIter base() const
{
return iter_;
}
}; // class 'void_ptr_iterator'
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator+( void_ptr_iterator<VoidIter,T> l,
BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n )
{
l += n;
return l;
}
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator+( BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n,
void_ptr_iterator<VoidIter,T> r )
{
r += n;
return r;
}
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator-( void_ptr_iterator<VoidIter,T> l,
BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n )
{
l -= n;
return l;
}
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator-( BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n,
void_ptr_iterator<VoidIter,T> r )
{
r -= n;
return r;
}
template< class VoidIter, class T, class VoidIterU, class U >
inline BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type
operator-( void_ptr_iterator<VoidIter,T> l,
void_ptr_iterator<VoidIterU,U> r )
{
return l.base() - r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator==( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() == r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator!=( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() != r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator<( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() < r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator<=( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() <= r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator>( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() > r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator>=( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() >= r.base();
}
}
#endif

View File

@@ -0,0 +1,58 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_EXCEPTION_HPP
#define BOOST_PTR_CONTAINER_EXCEPTION_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <exception>
namespace boost
{
class bad_ptr_container_operation : public std::exception
{
const char* what_;
public:
bad_ptr_container_operation( const char* what ) : what_( what )
{ }
virtual const char* what() const throw()
{
return what_;
}
};
class bad_index : public bad_ptr_container_operation
{
public:
bad_index( const char* what ) : bad_ptr_container_operation( what )
{ }
};
class bad_pointer : public bad_ptr_container_operation
{
public:
bad_pointer() : bad_ptr_container_operation( "Null pointer not allowed in a pointer container!" )
{ }
bad_pointer( const char* text ) : bad_ptr_container_operation( text )
{ }
};
}
#endif

View File

@@ -0,0 +1,151 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2007. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
#define BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_SFINAE
#else
#include <boost/utility/result_of.hpp>
#include <boost/pointee.hpp>
#endif // BOOST_NO_SFINAE
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_void.hpp>
#include <functional>
namespace boost
{
namespace ptr_container_detail
{
template <typename Type, typename Dummy>
struct make_lazy
{
typedef typename Type::type type;
};
}
template
<
class Fun
#ifdef BOOST_NO_SFINAE
, class Result = bool
#endif
>
class indirect_fun
{
Fun fun;
public:
indirect_fun() : fun(Fun())
{ }
indirect_fun( Fun f ) : fun(f)
{ }
template< class T >
#ifdef BOOST_NO_SFINAE
Result
#else
typename boost::result_of< const Fun( typename pointee<T>::type& ) >::type
#endif
operator()( const T& r ) const
{
return fun( *r );
}
template< class T, class U >
#ifdef BOOST_NO_SFINAE
Result
#else
typename boost::result_of< const Fun( typename pointee<T>::type&,
typename pointee<U>::type& ) >::type
#endif
operator()( const T& r, const U& r2 ) const
{
return fun( *r, *r2 );
}
};
template< class Fun >
inline indirect_fun<Fun> make_indirect_fun( Fun f )
{
return indirect_fun<Fun>( f );
}
template
<
class Fun,
class Arg1,
class Arg2 = Arg1
#ifdef BOOST_NO_SFINAE
, class Result = bool
#endif
>
class void_ptr_indirect_fun
{
Fun fun;
public:
void_ptr_indirect_fun() : fun(Fun())
{ }
void_ptr_indirect_fun( Fun f ) : fun(f)
{ }
template< class Void >
#ifdef BOOST_NO_SFINAE
Result
#else
typename ptr_container_detail::make_lazy<
boost::result_of<const Fun(const Arg1&)>, Void>::type
#endif
operator()( const Void* r ) const
{
BOOST_STATIC_ASSERT(boost::is_void<Void>::value);
BOOST_ASSERT( r != 0 );
return fun( * static_cast<const Arg1*>( r ) );
}
template< class Void >
#ifdef BOOST_NO_SFINAE
Result
#else
typename ptr_container_detail::make_lazy<
boost::result_of<const Fun(const Arg1&, const Arg2&)>, Void>::type
#endif
operator()( const Void* l, const Void* r ) const
{
BOOST_STATIC_ASSERT(boost::is_void<Void>::value);
BOOST_ASSERT( l != 0 && r != 0 );
return fun( * static_cast<const Arg1*>( l ), * static_cast<const Arg2*>( r ) );
}
};
template< class Arg, class Fun >
inline void_ptr_indirect_fun<Fun,Arg> make_void_ptr_indirect_fun( Fun f )
{
return void_ptr_indirect_fun<Fun,Arg>( f );
}
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,73 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
#define BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/config.hpp>
namespace boost
{
template< class T >
struct nullable
{
typedef T type;
};
namespace ptr_container_detail
{
template< class T >
type_traits::yes_type is_nullable( const nullable<T>* );
type_traits::no_type is_nullable( ... );
}
template< class T >
struct is_nullable
{
private:
BOOST_STATIC_CONSTANT( T*, var );
public:
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:6334)
#endif
BOOST_STATIC_CONSTANT(bool, value = sizeof( ptr_container_detail::is_nullable( var ) )
== sizeof( type_traits::yes_type ) );
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
};
template< class T >
struct remove_nullable
{
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< is_nullable<T>,
T,
mpl::identity<T> >::type
type;
};
}
#endif

View File

@@ -0,0 +1,234 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_ARRAY_HPP
#define BOOST_PTR_CONTAINER_PTR_ARRAY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/array.hpp>
#include <boost/static_assert.hpp>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class T,
size_t N,
class Allocator = int // dummy
>
class ptr_array_impl : public boost::array<T,N>
{
public:
typedef Allocator allocator_type;
ptr_array_impl( Allocator /*a*/ = Allocator() )
{
this->assign( 0 );
}
ptr_array_impl( size_t, T*, Allocator /*a*/ = Allocator() )
{
this->assign( 0 );
}
};
}
template
<
class T,
size_t N,
class CloneAllocator = heap_clone_allocator
>
class ptr_array : public
ptr_sequence_adapter< T,
ptr_container_detail::ptr_array_impl<void*,N>,
CloneAllocator >
{
private:
typedef ptr_sequence_adapter< T,
ptr_container_detail::ptr_array_impl<void*,N>,
CloneAllocator >
base_class;
typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type U;
typedef ptr_array<T,N,CloneAllocator>
this_type;
public:
typedef std::size_t size_type;
typedef U* value_type;
typedef U* pointer;
typedef U& reference;
typedef const U& const_reference;
typedef BOOST_DEDUCED_TYPENAME base_class::auto_type
auto_type;
public: // constructors
ptr_array() : base_class()
{ }
ptr_array( const ptr_array& r )
{
size_t i = 0;
for( ; i != N; ++i )
this->base()[i] = this->null_policy_allocate_clone(
static_cast<const T*>( &r[i] ) );
}
template< class U >
ptr_array( const ptr_array<U,N>& r )
{
size_t i = 0;
for( ; i != N; ++i )
this->base()[i] = this->null_policy_allocate_clone(
static_cast<const T*>( &r[i] ) );
}
explicit ptr_array( std::auto_ptr<this_type> r )
: base_class( r ) { }
ptr_array& operator=( ptr_array r )
{
this->swap( r );
return *this;
}
ptr_array& operator=( std::auto_ptr<this_type> r )
{
base_class::operator=(r);
return *this;
}
std::auto_ptr<this_type> release()
{
std::auto_ptr<this_type> ptr( new this_type );
this->swap( *ptr );
return ptr;
}
std::auto_ptr<this_type> clone() const
{
std::auto_ptr<this_type> pa( new this_type );
for( size_t i = 0; i != N; ++i )
{
if( ! is_null(i) )
pa->replace( i, this->null_policy_allocate_clone( &(*this)[i] ) );
}
return pa;
}
private: // hide some members
using base_class::insert;
using base_class::erase;
using base_class::push_back;
using base_class::push_front;
using base_class::pop_front;
using base_class::pop_back;
using base_class::transfer;
using base_class::get_allocator;
public: // compile-time interface
template< size_t idx >
auto_type replace( U* r ) // strong
{
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
}
template< size_t idx, class V >
auto_type replace( std::auto_ptr<V> r )
{
return replace<idx>( r.release() );
}
auto_type replace( size_t idx, U* r ) // strong
{
this->enforce_null_policy( r, "Null pointer in 'ptr_array::replace()'" );
auto_type ptr( r );
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
}
template< class V >
auto_type replace( size_t idx, std::auto_ptr<V> r )
{
return replace( idx, r.release() );
}
using base_class::at;
template< size_t idx >
T& at()
{
BOOST_STATIC_ASSERT( idx < N );
return (*this)[idx];
}
template< size_t idx >
const T& at() const
{
BOOST_STATIC_ASSERT( idx < N );
return (*this)[idx];
}
bool is_null( size_t idx ) const
{
return base_class::is_null(idx);
}
template< size_t idx >
bool is_null() const
{
BOOST_STATIC_ASSERT( idx < N );
return this->base()[idx] == 0;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, size_t size, typename CA >
inline ptr_array<T,size,CA>* new_clone( const ptr_array<T,size,CA>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, size_t size, typename CA >
inline void swap( ptr_array<T,size,CA>& l, ptr_array<T,size,CA>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,531 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_CIRCULAR_BUFFER_HPP
#define BOOST_PTR_CONTAINER_PTR_CIRCULAR_BUFFER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/circular_buffer.hpp>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_circular_buffer : public
ptr_sequence_adapter< T,
boost::circular_buffer<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
boost::circular_buffer<void*,Allocator>,
CloneAllocator >
base_type;
typedef boost::circular_buffer<void*,Allocator> circular_buffer_type;
typedef ptr_circular_buffer<T,CloneAllocator,Allocator> this_type;
public: // typedefs
typedef typename base_type::value_type value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef typename base_type::size_type size_type;
typedef typename base_type::allocator_type allocator_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::auto_type auto_type;
typedef std::pair<pointer,size_type> array_range;
typedef std::pair<const_pointer,size_type> const_array_range;
typedef typename circular_buffer_type::capacity_type capacity_type;
public: // constructors
ptr_circular_buffer()
{ }
explicit ptr_circular_buffer( capacity_type n )
: base_type( n, ptr_container_detail::fixed_length_sequence_tag() )
{ }
ptr_circular_buffer( capacity_type n,
const allocator_type& alloc )
: base_type( n, alloc, ptr_container_detail::fixed_length_sequence_tag() )
{ }
template< class ForwardIterator >
ptr_circular_buffer( ForwardIterator first, ForwardIterator last )
: base_type( first, last, ptr_container_detail::fixed_length_sequence_tag() )
{ }
template< class InputIterator >
ptr_circular_buffer( capacity_type n, InputIterator first, InputIterator last )
: base_type( n, first, last, ptr_container_detail::fixed_length_sequence_tag() )
{ }
ptr_circular_buffer( const ptr_circular_buffer& r )
: base_type( r.size(), r.begin(), r.end(),
ptr_container_detail::fixed_length_sequence_tag() )
{ }
template< class U >
ptr_circular_buffer( const ptr_circular_buffer<U>& r )
: base_type( r.size(), r.begin(), r.end(),
ptr_container_detail::fixed_length_sequence_tag() )
{ }
ptr_circular_buffer& operator=( ptr_circular_buffer r )
{
this->swap( r );
return *this;
}
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_circular_buffer,
base_type, this_type )
public: // allocators
allocator_type& get_allocator()
{
return this->base().get_allocator();
}
allocator_type get_allocator() const
{
return this->base().get_allocator();
}
public: // circular buffer functions
array_range array_one() // nothrow
{
typename circular_buffer_type::array_range r = this->base().array_one();
return array_range( reinterpret_cast<pointer>(r.first), r.second );
}
const_array_range array_one() const // nothrow
{
typename circular_buffer_type::const_array_range r = this->base().array_one();
return const_array_range( reinterpret_cast<const_pointer>(r.first), r.second );
}
array_range array_two() // nothrow
{
typename circular_buffer_type::array_range r = this->base().array_two();
return array_range( reinterpret_cast<pointer>(r.first), r.second );
}
const_array_range array_two() const // nothrow
{
typename circular_buffer_type::const_array_range r = this->base().array_two();
return const_array_range( reinterpret_cast<const_pointer>(r.first), r.second );
}
pointer linearize() // nothrow
{
return reinterpret_cast<pointer>(this->base().linearize());
}
bool full() const // nothrow
{
return this->base().full();
}
size_type reserve() const // nothrow
{
return this->base().reserve();
}
void reserve( size_type n ) // strong
{
if( capacity() < n )
set_capacity( n );
}
capacity_type capacity() const // nothrow
{
return this->base().capacity();
}
void set_capacity( capacity_type new_capacity ) // strong
{
if( this->size() > new_capacity )
{
this->erase( this->begin() + new_capacity, this->end() );
}
this->base().set_capacity( new_capacity );
}
void rset_capacity( capacity_type new_capacity ) // strong
{
if( this->size() > new_capacity )
{
this->erase( this->begin(),
this->begin() + (this->size()-new_capacity) );
}
this->base().rset_capacity( new_capacity );
}
void resize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void resize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
template< class InputIterator >
void assign( InputIterator first, InputIterator last ) // strong
{
ptr_circular_buffer temp( first, last );
this->swap( temp );
}
template< class Range >
void assign( const Range& r ) // strong
{
assign( boost::begin(r), boost::end(r ) );
}
void assign( size_type n, value_type to_clone ) // strong
{
ptr_circular_buffer temp( n );
for( size_type i = 0u; i != n; ++i )
temp.push_back( this->null_policy_allocate_clone( to_clone ) );
this->swap( temp );
}
void assign( capacity_type capacity, size_type n,
value_type to_clone ) // basic
{
this->assign( (std::min)(n,capacity), to_clone );
}
template< class InputIterator >
void assign( capacity_type capacity,
InputIterator first, InputIterator last ) // basic
{
this->assign( first, last );
this->set_capacity( capacity );
}
void push_back( value_type ptr ) // nothrow
{
BOOST_ASSERT( capacity() > 0 );
this->enforce_null_policy( ptr, "Null pointer in 'push_back()'" );
auto_type old_ptr;
if( full() )
old_ptr.reset( &*this->begin() );
this->base().push_back( ptr );
}
template< class U >
void push_back( std::auto_ptr<U> ptr ) // nothrow
{
push_back( ptr.release() );
}
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;
if( full() )
old_ptr.reset( &*(--this->end()) );
this->base().push_front( ptr );
}
template< class U >
void push_front( std::auto_ptr<U> ptr ) // nothrow
{
push_front( ptr.release() );
}
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 );
iterator b = this->begin();
if( full() && pos == b )
return b;
auto_type old_ptr;
if( full() )
old_ptr.reset( &*this->begin() );
new_ptr.release();
return this->base().insert( pos.base(), ptr );
}
template< class U >
iterator insert( iterator pos, std::auto_ptr<U> ptr ) // nothrow
{
return insert( pos, ptr.release() );
}
template< class InputIterator >
void insert( iterator pos, InputIterator first, InputIterator last ) // basic
{
for( ; first != last; ++first, ++pos )
pos = insert( pos, this->null_policy_allocate_clone( &*first ) );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( iterator before, const Range& r )
{
insert( before, boost::begin(r), boost::end(r) );
}
#endif
iterator rinsert( iterator pos, value_type ptr ) // nothrow
{
BOOST_ASSERT( capacity() > 0 );
this->enforce_null_policy( ptr, "Null pointer in 'rinsert()'" );
auto_type new_ptr( ptr );
iterator b = this->end();
if (full() && pos == b)
return b;
auto_type old_ptr;
if( full() )
old_ptr.reset( &this->back() );
new_ptr.release();
return this->base().rinsert( pos.base(), ptr );
}
template< class U >
iterator rinsert( iterator pos, std::auto_ptr<U> ptr ) // nothrow
{
return rinsert( pos, ptr.release() );
}
template< class InputIterator >
void rinsert( iterator pos, InputIterator first, InputIterator last ) // basic
{
for( ; first != last; ++first, ++pos )
pos = rinsert( pos, this->null_policy_allocate_clone( &*first ) );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
rinsert( iterator before, const Range& r )
{
rinsert( before, boost::begin(r), boost::end(r) );
}
#endif
iterator rerase( iterator pos ) // nothrow
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( pos != this->end() );
this->remove( pos );
return iterator( this->base().rerase( pos.base() ) );
}
iterator rerase( iterator first, iterator last ) // nothrow
{
this->remove( first, last );
return iterator( this->base().rerase( first.base(),
last.base() ) );
}
template< class Range >
iterator rerase( const Range& r ) // nothrow
{
return rerase( boost::begin(r), boost::end(r) );
}
void rotate( const_iterator new_begin ) // nothrow
{
this->base().rotate( new_begin.base() );
}
public: // transfer
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator last,
PtrSeqAdapter& from ) // nothrow
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
for( BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator begin = first;
begin != last; ++begin, ++before )
before = insert( before, &*begin ); // nothrow
from.base().erase( first.base(), last.base() ); // nothrow
}
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator object,
PtrSeqAdapter& from ) // nothrow
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
insert( before, &*object ); // nothrow
from.base().erase( object.base() ); // nothrow
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSeqAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator > >::type
transfer( iterator before, const Range& r, PtrSeqAdapter& from ) // nothrow
{
transfer( before, boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSeqAdapter >
void transfer( iterator before, PtrSeqAdapter& from ) // nothrow
{
transfer( before, from.begin(), from.end(), from );
}
public: // C-array support
void transfer( iterator before, value_type* from,
size_type size, bool delete_from = true ) // nothrow
{
BOOST_ASSERT( from != 0 );
if( delete_from )
{
BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
deleter( from, size ); // nothrow
for( size_type i = 0u; i != size; ++i, ++before )
before = insert( before, *(from+i) ); // nothrow
deleter.release(); // nothrow
}
else
{
for( size_type i = 0u; i != size; ++i, ++before )
before = insert( before, *(from+i) ); // nothrow
}
}
value_type* c_array() // nothrow
{
if( this->empty() )
return 0;
this->linearize();
T** res = reinterpret_cast<T**>( &this->begin().base()[0] );
return res;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_circular_buffer<T,CA,A>* new_clone( const ptr_circular_buffer<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_circular_buffer<T,CA,A>& l, ptr_circular_buffer<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,31 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/ptr_array.hpp>
#include <boost/ptr_container/ptr_deque.hpp>
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_set.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ptr_container/ptr_unordered_map.hpp>
#include <boost/ptr_container/ptr_unordered_set.hpp>
#include <boost/ptr_container/ptr_circular_buffer.hpp>
#include <boost/ptr_container/ptr_inserter.hpp>
#endif

View File

@@ -0,0 +1,69 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_DEQUE_HPP
#define BOOST_PTR_CONTAINER_PTR_DEQUE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <deque>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_deque : public
ptr_sequence_adapter< T,
std::deque<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
std::deque<void*,Allocator>,
CloneAllocator >
base_class;
typedef ptr_deque<T,CloneAllocator,Allocator> this_type;
public:
BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_deque,
base_class,
this_type )
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_deque<T,CA,A>* new_clone( const ptr_deque<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_deque<T,CA,A>& l, ptr_deque<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,258 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_INSERTER_HPP
#define BOOST_PTR_CONTAINER_PTR_INSERTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <iterator>
#include <memory>
namespace boost
{
namespace ptr_container
{
template< class PtrContainer >
class ptr_back_insert_iterator;
template< class PtrContainer >
class ptr_front_insert_iterator;
template< class PtrContainer >
class ptr_insert_iterator;
template< class PtrContainer >
ptr_back_insert_iterator<PtrContainer>
ptr_back_inserter( PtrContainer& cont );
template< class PtrContainer >
ptr_front_insert_iterator<PtrContainer>
ptr_front_inserter( PtrContainer& cont );
template< class PtrContainer >
ptr_insert_iterator<PtrContainer>
ptr_inserter( PtrContainer& cont, typename PtrContainer::iterator before );
//////////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////////
template< class PtrContainer >
class ptr_back_insert_iterator :
public std::iterator<std::output_iterator_tag,void,void,void,void>
{
public:
typedef PtrContainer container_type;
public:
explicit ptr_back_insert_iterator( PtrContainer& cont )
: container(&cont)
{ }
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);
container->push_back( obj );
return *this;
}
template< class T >
ptr_back_insert_iterator&
operator=( std::auto_ptr<T> r )
{
container->push_back( r );
return *this;
}
ptr_back_insert_iterator&
operator=( typename PtrContainer::const_reference r )
{
container->push_back( container_type::clone_allocator_type::
allocate_clone(r) );
return *this;
}
ptr_back_insert_iterator& operator*()
{
return *this;
}
ptr_back_insert_iterator& operator++()
{
return *this;
}
ptr_back_insert_iterator operator++(int)
{
return *this;
}
protected:
PtrContainer* container;
};
template< class PtrContainer >
class ptr_front_insert_iterator :
public std::iterator<std::output_iterator_tag,void,void,void,void>
{
public:
typedef PtrContainer container_type;
public:
explicit ptr_front_insert_iterator( PtrContainer& cont )
: container(&cont)
{ }
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);
container->push_front( obj );
return *this;
}
template< class T >
ptr_front_insert_iterator&
operator=( std::auto_ptr<T> r )
{
container->push_front( r );
return *this;
}
ptr_front_insert_iterator&
operator=( typename PtrContainer::const_reference r )
{
container->push_front( container_type::clone_allocator_type::
allocate_clone(r) );
return *this;
}
ptr_front_insert_iterator& operator*()
{
return *this;
}
ptr_front_insert_iterator& operator++()
{
return *this;
}
ptr_front_insert_iterator operator++(int)
{
return *this;
}
protected:
PtrContainer* container;
};
template< class PtrContainer >
class ptr_insert_iterator :
public std::iterator<std::output_iterator_tag,void,void,void,void>
{
public:
typedef PtrContainer container_type;
public:
ptr_insert_iterator( PtrContainer& cont,
typename PtrContainer::iterator before )
: container(&cont), iter(before)
{ }
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);
iter = container->insert( iter, obj );
return *this;
}
template< class T >
ptr_insert_iterator&
operator=( std::auto_ptr<T> r )
{
iter = container->insert( iter, r );
return *this;
}
ptr_insert_iterator&
operator=( typename PtrContainer::const_reference r )
{
iter = container->insert( iter, container_type::clone_allocator_type::
allocate_clone(r) );
return *this;
}
ptr_insert_iterator& operator*()
{
return *this;
}
ptr_insert_iterator& operator++()
{
return *this;
}
ptr_insert_iterator operator++(int)
{
return *this;
}
protected:
PtrContainer* container;
typename PtrContainer::iterator iter;
};
template< class PtrContainer >
inline ptr_back_insert_iterator<PtrContainer>
ptr_back_inserter( PtrContainer& cont )
{
return ptr_back_insert_iterator<PtrContainer>( cont );
}
template< class PtrContainer >
inline ptr_front_insert_iterator<PtrContainer>
ptr_front_inserter( PtrContainer& cont )
{
return ptr_front_insert_iterator<PtrContainer>( cont );
}
template< class PtrContainer >
inline ptr_insert_iterator<PtrContainer>
ptr_inserter( PtrContainer& cont,
typename PtrContainer::iterator before )
{
return ptr_insert_iterator<PtrContainer>( cont, before );
}
} // namespace 'ptr_container'
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,110 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_LIST_HPP
#define BOOST_PTR_CONTAINER_PTR_LIST_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
#include <list>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_list : public
ptr_sequence_adapter< T,
std::list<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
std::list<void*,Allocator>,
CloneAllocator >
base_class;
typedef ptr_list<T,CloneAllocator,Allocator> this_type;
public:
BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_list,
base_class,
this_type )
typedef BOOST_DEDUCED_TYPENAME base_class::value_type value_type;
public:
using base_class::merge;
void merge( ptr_list& x )
{
merge( x, std::less<T>() );
}
template< typename Compare >
void merge( ptr_list& x, Compare comp )
{
this->base().merge( x.base(), void_ptr_indirect_fun<Compare,T>( comp ) ); }
void sort()
{
sort( std::less<T>() );
};
template< typename Compare >
void sort( Compare comp )
{
this->base().sort( void_ptr_indirect_fun<Compare,T>( comp ) );
}
template< class Pred >
void erase_if( iterator first, iterator last, Pred pred )
{
base_class::erase_if( first, last, pred );
}
template< class Pred >
void erase_if( Pred pred )
{
this->base().remove_if( BOOST_DEDUCED_TYPENAME base_class::
BOOST_NESTED_TEMPLATE void_ptr_delete_if<Pred,value_type>
(pred) );
}
}; // class 'ptr_list'
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_list<T,CA,A>* new_clone( const ptr_list<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_list<T,CA,A>& l, ptr_list<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

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

View File

@@ -0,0 +1,874 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_PTR_MAP_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_PTR_MAP_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#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/static_assert.hpp>
#include <boost/range/iterator_range.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class T,
class VoidPtrMap,
bool Ordered
>
struct map_config
{
typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type
U;
typedef VoidPtrMap
void_container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_value_compare<VoidPtrMap>,
mpl::identity<void> >::type
value_compare;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_key_compare<VoidPtrMap>,
mpl::identity<void> >::type
key_compare;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_hasher<VoidPtrMap> >::type
hasher;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_key_equal<VoidPtrMap> >::type
key_equal;
typedef BOOST_DEDUCED_TYPENAME
mpl::if_c<Ordered,
ptr_container_detail::ordered_associative_container_tag,
ptr_container_detail::unordered_associative_container_tag>::type
container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::key_type
key_type;
typedef U value_type;
typedef ptr_map_iterator< BOOST_DEDUCED_TYPENAME VoidPtrMap::iterator, key_type, U* const >
iterator;
typedef ptr_map_iterator< BOOST_DEDUCED_TYPENAME VoidPtrMap::const_iterator, key_type, const U* const>
const_iterator;
typedef ptr_map_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrMap>,
select_local_iterator<VoidPtrMap> >::type,
key_type, U* const >
local_iterator;
typedef ptr_map_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrMap>,
select_const_local_iterator<VoidPtrMap> >::type,
key_type, const U* const >
const_local_iterator;
template< class Iter >
static U* get_pointer( Iter i )
{
return i->second;
}
template< class Iter >
static const U* get_const_pointer( Iter i )
{
return i->second;
}
BOOST_STATIC_CONSTANT( bool, allow_null = boost::is_nullable<T>::value );
};
template
<
class T,
class VoidPtrMap,
class CloneAllocator,
bool Ordered
>
class ptr_map_adapter_base :
public ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap,Ordered>,
CloneAllocator >
{
typedef ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap,Ordered>,
CloneAllocator >
base_type;
typedef map_config<T,VoidPtrMap,Ordered> config;
typedef ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered> this_type;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME base_type::value_type
mapped_type;
typedef BOOST_DEDUCED_TYPENAME base_type::reference
mapped_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_mapped_reference;
typedef BOOST_DEDUCED_TYPENAME iterator_value<iterator>::type
value_type;
typedef value_type
reference;
typedef BOOST_DEDUCED_TYPENAME iterator_value<const_iterator>::type
const_reference;
typedef value_type
pointer;
typedef const_reference
const_pointer;
private:
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" );
}
struct eraser // scope guard
{
bool released_;
VoidPtrMap* m_;
const key_type& key_;
eraser( VoidPtrMap* m, const key_type& key )
: released_(false), m_(m), key_(key)
{}
~eraser()
{
if( !released_ )
m_->erase(key_);
}
void release() { released_ = true; }
private:
eraser& operator=(const eraser&);
};
mapped_reference insert_lookup( const key_type& key )
{
void*& ref = this->base()[key];
if( ref )
{
return *static_cast<mapped_type>(ref);
}
else
{
eraser e(&this->base(),key); // nothrow
mapped_type res = new T(); // strong
ref = res; // nothrow
e.release(); // nothrow
return *res;
}
}
public:
ptr_map_adapter_base()
{ }
template< class SizeType >
explicit ptr_map_adapter_base( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Compare, class Allocator >
ptr_map_adapter_base( const Compare& comp,
const Allocator& a )
: base_type( comp, a )
{ }
template< class Hash, class Pred, class Allocator >
ptr_map_adapter_base( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_map_adapter_base( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Comp >
ptr_map_adapter_base( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( first, last, comp, a )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_map_adapter_base( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class PtrContainer >
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 )
{
base_type::operator=( clone );
return *this;
}
iterator find( const key_type& x )
{
return iterator( this->base().find( x ) );
}
const_iterator find( const key_type& x ) const
{
return const_iterator( this->base().find( x ) );
}
size_type count( const key_type& x ) const
{
return this->base().count( x );
}
iterator lower_bound( const key_type& x )
{
return iterator( this->base().lower_bound( x ) );
}
const_iterator lower_bound( const key_type& x ) const
{
return const_iterator( this->base().lower_bound( x ) );
}
iterator upper_bound( const key_type& x )
{
return iterator( this->base().upper_bound( x ) );
}
const_iterator upper_bound( const key_type& x ) const
{
return const_iterator( this->base().upper_bound( x ) );
}
iterator_range<iterator> equal_range( const key_type& x )
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator>
p = this->base().equal_range( x );
return make_iterator_range( iterator( p.first ), iterator( p.second ) );
}
iterator_range<const_iterator> equal_range( const key_type& x ) const
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator>
p = this->base().equal_range( x );
return make_iterator_range( const_iterator( p.first ),
const_iterator( p.second ) );
}
mapped_reference at( const key_type& key )
{
return const_cast<mapped_reference>( lookup( key ) );
}
const_mapped_reference at( const key_type& key ) const
{
return lookup( key );
}
mapped_reference operator[]( const key_type& key )
{
return insert_lookup( key );
}
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 );
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
return boost::ptr_container::move( old );
}
template< class U >
auto_type replace( iterator where, std::auto_ptr<U> x )
{
return replace( where, x.release() );
}
protected:
size_type bucket( const key_type& key ) const
{
return this->base().bucket( key );
}
};
} // ptr_container_detail
/////////////////////////////////////////////////////////////////////////
// ptr_map_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class T,
class VoidPtrMap,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_map_adapter :
public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>
base_type;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
mapped_type;
private:
void safe_insert( const key_type& key, auto_type ptr ) // strong
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
res =
this->base().insert( std::make_pair( key, ptr.get() ) ); // strong, commit
if( res.second ) // nothrow
ptr.release(); // nothrow
}
template< class II >
void map_basic_clone_and_insert( II first, II last )
{
while( first != last )
{
if( this->find( first->first ) == this->end() )
{
const_reference p = *first.base(); // nothrow
auto_type ptr( this->null_policy_allocate_clone( p.second ) );
// strong
this->safe_insert( p.first,
boost::ptr_container::move( ptr ) );
// strong, commit
}
++first;
}
}
public:
ptr_map_adapter( )
{ }
template< class Comp >
explicit ptr_map_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a ) { }
template< class Hash, class Pred, class Allocator >
ptr_map_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_map_adapter( InputIterator first, InputIterator last )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Comp >
ptr_map_adapter( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( comp, a )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_map_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{
map_basic_clone_and_insert( first, last );
}
ptr_map_adapter( const ptr_map_adapter& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class Key, class U, class CA, bool b >
ptr_map_adapter( const ptr_map_adapter<Key,U,CA,b>& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class U >
ptr_map_adapter( std::auto_ptr<U> r ) : base_type( r )
{ }
ptr_map_adapter& operator=( ptr_map_adapter r )
{
this->swap( r );
return *this;
}
template< class U >
ptr_map_adapter& operator=( std::auto_ptr<U> r )
{
base_type::operator=( r );
return *this;
}
using base_type::release;
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
map_basic_clone_and_insert( first, last );
}
template< class Range >
void insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
private:
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
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
ptr.release(); // nothrow
return std::make_pair( iterator( res.first ), res.second ); // nothrow
}
iterator insert_impl( iterator before, 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
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( before.base(), std::make_pair( key, x ) );
// strong, commit
ptr.release(); // notrow
return iterator( res );
}
public:
std::pair<iterator,bool> insert( key_type& key, mapped_type x )
{
return insert_impl( key, x );
}
template< class U >
std::pair<iterator,bool> insert( const key_type& key, std::auto_ptr<U> x )
{
return insert_impl( key, x.release() );
}
template< class F, class S >
iterator insert( iterator before, ptr_container_detail::ref_pair<F,S> p ) // strong
{
this->enforce_null_policy( p.second,
"Null pointer in 'ptr_map_adapter::insert()'" );
auto_type ptr( this->null_policy_allocate_clone( p.second ) );
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
result = this->base().insert( before.base(),
std::make_pair(p.first,ptr.get()) ); // strong
if( ptr.get() == result->second )
ptr.release();
return iterator( result );
}
iterator insert( iterator before, key_type& key, mapped_type x ) // strong
{
return insert_impl( before, key, x );
}
template< class U >
iterator insert( iterator before, const key_type& key, std::auto_ptr<U> x ) // strong
{
return insert_impl( before, key, x.release() );
}
template< class PtrMapAdapter >
bool transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object,
PtrMapAdapter& from ) // strong
{
return this->single_transfer( object, from );
}
template< class PtrMapAdapter >
size_type transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator last,
PtrMapAdapter& from ) // basic
{
return this->single_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrMapAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator >,
size_type >::type
transfer( const Range& r, PtrMapAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrMapAdapter >
size_type transfer( PtrMapAdapter& from ) // basic
{
return transfer( from.begin(), from.end(), from );
}
};
/////////////////////////////////////////////////////////////////////////
// ptr_multimap_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class T,
class VoidPtrMultiMap,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_multimap_adapter :
public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator,Ordered>
base_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
mapped_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiMap::allocator_type
allocator_type;
private:
void safe_insert( const key_type& key, auto_type ptr ) // strong
{
this->base().insert(
std::make_pair( key, ptr.get() ) ); // strong, commit
ptr.release(); // nothrow
}
template< typename II >
void map_basic_clone_and_insert( II first, II last )
{
while( first != last )
{
const_reference pair = *first.base(); // nothrow
auto_type ptr( this->null_policy_allocate_clone( pair.second ) );
// strong
safe_insert( pair.first,
boost::ptr_container::move( ptr ) );
// strong, commit
++first;
}
}
public:
ptr_multimap_adapter()
{ }
template< class SizeType >
ptr_multimap_adapter( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Comp >
explicit ptr_multimap_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a ) { }
template< class Hash, class Pred, class Allocator >
ptr_multimap_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_multimap_adapter( InputIterator first, InputIterator last )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Comp >
ptr_multimap_adapter( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a )
: base_type( comp, a )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_multimap_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{
map_basic_clone_and_insert( first, last );
}
ptr_multimap_adapter( const ptr_multimap_adapter& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class Key, class U, class CA, bool b >
ptr_multimap_adapter( const ptr_multimap_adapter<Key,U,CA,b>& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class U >
explicit ptr_multimap_adapter( std::auto_ptr<U> r ) : base_type( r )
{ }
ptr_multimap_adapter& operator=( ptr_multimap_adapter r )
{
this->swap( r );
return *this;
}
template< class U >
ptr_multimap_adapter& operator=( std::auto_ptr<U> r )
{
base_type::operator=( r );
return *this;
}
using base_type::release;
private:
iterator insert_impl( const key_type& key, mapped_type x ) // strong
{
this->enforce_null_policy( x,
"Null pointer in 'ptr_multimap_adapter::insert()'" );
auto_type ptr( x ); // nothrow
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( std::make_pair( key, x ) );
// strong, commit
ptr.release(); // notrow
return iterator( res );
}
iterator insert_impl( iterator before, const key_type& key, mapped_type x ) // strong
{
this->enforce_null_policy( x,
"Null pointer in 'ptr_multimap_adapter::insert()'" );
auto_type ptr( x ); // nothrow
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( before.base(),
std::make_pair( key, x ) );
// strong, commit
ptr.release(); // notrow
return iterator( res );
}
public:
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
map_basic_clone_and_insert( first, last );
}
template< class Range >
void insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
iterator insert( key_type& key, mapped_type x ) // strong
{
return insert_impl( key, x );
}
template< class U >
iterator insert( const key_type& key, std::auto_ptr<U> x )
{
return insert_impl( key, x.release() );
}
template< class F, class S >
iterator insert( iterator before, ptr_container_detail::ref_pair<F,S> p ) // strong
{
this->enforce_null_policy( p.second,
"Null pointer in 'ptr_multimap_adapter::insert()'" );
iterator res = insert_impl( before, p.first,
this->null_policy_allocate_clone( p.second ) );
return res;
}
iterator insert( iterator before, key_type& key, mapped_type x ) // strong
{
return insert_impl( before, key, x );
}
template< class U >
iterator insert( iterator before, const key_type& key, std::auto_ptr<U> x ) // strong
{
return insert_impl( before, key, x.release() );
}
template< class PtrMapAdapter >
void transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object,
PtrMapAdapter& from ) // strong
{
this->multi_transfer( object, from );
}
template< class PtrMapAdapter >
size_type transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator last,
PtrMapAdapter& from ) // basic
{
return this->multi_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrMapAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator >,
size_type >::type
transfer( const Range& r, PtrMapAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrMapAdapter >
void transfer( PtrMapAdapter& from ) // basic
{
transfer( from.begin(), from.end(), from );
BOOST_ASSERT( from.empty() );
}
};
template< class I, class F, class S >
inline bool is_null( const ptr_map_iterator<I,F,S>& i )
{
return i->second == 0;
}
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,775 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_SEQUENCE_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_PTR_SEQUENCE_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#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/type_traits/remove_pointer.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class T,
class VoidPtrSeq
>
struct sequence_config
{
typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type
U;
typedef VoidPtrSeq
void_container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSeq::allocator_type
allocator_type;
typedef U value_type;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSeq::iterator, U >
iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSeq::const_iterator, const U >
const_iterator;
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
template< class Iter >
static U* get_pointer( Iter i )
{
return static_cast<U*>( *i.base() );
}
#else
template< class Iter >
static U* get_pointer( void_ptr_iterator<Iter,U> i )
{
return static_cast<U*>( *i.base() );
}
template< class Iter >
static U* get_pointer( Iter i )
{
return &*i;
}
#endif
#if defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
template< class Iter >
static const U* get_const_pointer( Iter i )
{
return static_cast<const U*>( *i.base() );
}
#else // BOOST_NO_SFINAE
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
template< class Iter >
static const U* get_const_pointer( void_ptr_iterator<Iter,U> i )
{
return static_cast<const U*>( *i.base() );
}
#else // BOOST_WORKAROUND
template< class Iter >
static const U* get_const_pointer( void_ptr_iterator<Iter,const U> i )
{
return static_cast<const U*>( *i.base() );
}
#endif // BOOST_WORKAROUND
template< class Iter >
static const U* get_const_pointer( Iter i )
{
return &*i;
}
#endif // BOOST_NO_SFINAE
BOOST_STATIC_CONSTANT(bool, allow_null = boost::is_nullable<T>::value );
};
} // ptr_container_detail
template< class Iterator, class T >
inline bool is_null( void_ptr_iterator<Iterator,T> i )
{
return *i.base() == 0;
}
template
<
class T,
class VoidPtrSeq,
class CloneAllocator = heap_clone_allocator
>
class ptr_sequence_adapter : public
ptr_container_detail::reversible_ptr_container< ptr_container_detail::sequence_config<T,VoidPtrSeq>,
CloneAllocator >
{
typedef ptr_container_detail::reversible_ptr_container< ptr_container_detail::sequence_config<T,VoidPtrSeq>,
CloneAllocator >
base_type;
typedef ptr_sequence_adapter<T,VoidPtrSeq,CloneAllocator>
this_type;
protected:
typedef BOOST_DEDUCED_TYPENAME base_type::scoped_deleter scoped_deleter;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME base_type::reference reference;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type auto_type;
typedef BOOST_DEDUCED_TYPENAME base_type::clone_allocator_type
clone_allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type
allocator_type;
ptr_sequence_adapter()
{ }
template< class Allocator >
explicit ptr_sequence_adapter( const Allocator& a )
: base_type( a )
{ }
template< class SizeType >
ptr_sequence_adapter( SizeType n,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( n, tag )
{ }
template< class SizeType, class Allocator >
ptr_sequence_adapter( SizeType n, const Allocator& a,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( n, a, tag )
{ }
template< class InputIterator >
ptr_sequence_adapter( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Allocator >
ptr_sequence_adapter( InputIterator first, InputIterator last,
const Allocator& a )
: base_type( first, last, a )
{ }
template< class ForwardIterator >
ptr_sequence_adapter( ForwardIterator first,
ForwardIterator last,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( first, last, tag )
{ }
template< class SizeType, class ForwardIterator >
ptr_sequence_adapter( SizeType n,
ForwardIterator first,
ForwardIterator last,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( n, first, last, tag )
{ }
ptr_sequence_adapter( const ptr_sequence_adapter& r )
: base_type( r )
{ }
template< class U >
ptr_sequence_adapter( const ptr_sequence_adapter<U,VoidPtrSeq,CloneAllocator>& r )
: base_type( r )
{ }
ptr_sequence_adapter( const ptr_sequence_adapter& r,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( r, tag )
{ }
template< class U >
ptr_sequence_adapter( const ptr_sequence_adapter<U,VoidPtrSeq,CloneAllocator>& r,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( r, tag )
{ }
template< class PtrContainer >
explicit ptr_sequence_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
ptr_sequence_adapter& operator=( const ptr_sequence_adapter r )
{
this->swap( r );
return *this;
}
template< class PtrContainer >
ptr_sequence_adapter& operator=( std::auto_ptr<PtrContainer> clone )
{
base_type::operator=( clone );
return *this;
}
/////////////////////////////////////////////////////////////
// modifiers
/////////////////////////////////////////////////////////////
void push_back( value_type x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'push_back()'" );
auto_type ptr( x ); // notrow
this->base().push_back( x ); // strong, commit
ptr.release(); // nothrow
}
template< class U >
void push_back( std::auto_ptr<U> x )
{
push_back( x.release() );
}
void push_front( value_type x )
{
this->enforce_null_policy( x, "Null pointer in 'push_front()'" );
auto_type ptr( x ); // nothrow
this->base().push_front( x ); // strong, commit
ptr.release(); // nothrow
}
template< class U >
void push_front( std::auto_ptr<U> x )
{
push_front( x.release() );
}
auto_type pop_back()
{
BOOST_ASSERT( !this->empty() &&
"'pop_back()' on empty container" );
auto_type ptr( static_cast<value_type>( this->base().back() ) );
// nothrow
this->base().pop_back(); // nothrow
return ptr_container_detail::move( ptr ); // nothrow
}
auto_type pop_front()
{
BOOST_ASSERT( !this->empty() &&
"'pop_front()' on empty container" );
auto_type ptr( static_cast<value_type>( this->base().front() ) );
// nothrow
this->base().pop_front(); // nothrow
return ptr_container_detail::move( ptr );
}
reference front()
{
BOOST_ASSERT( !this->empty() &&
"accessing 'front()' on empty container" );
BOOST_ASSERT( !::boost::is_null( this->begin() ) );
return *this->begin();
}
const_reference front() const
{
return const_cast<ptr_sequence_adapter*>(this)->front();
}
reference back()
{
BOOST_ASSERT( !this->empty() &&
"accessing 'back()' on empty container" );
BOOST_ASSERT( !::boost::is_null( --this->end() ) );
return *--this->end();
}
const_reference back() const
{
return const_cast<ptr_sequence_adapter*>(this)->back();
}
public: // deque/vector inerface
reference operator[]( size_type n ) // nothrow
{
BOOST_ASSERT( n < this->size() );
BOOST_ASSERT( !this->is_null( n ) );
return *static_cast<value_type>( this->base()[n] );
}
const_reference operator[]( size_type n ) const // nothrow
{
BOOST_ASSERT( n < this->size() );
BOOST_ASSERT( !this->is_null( n ) );
return *static_cast<value_type>( this->base()[n] );
}
reference at( size_type n )
{
BOOST_PTR_CONTAINER_THROW_EXCEPTION( n >= this->size(), bad_index,
"'at()' out of bounds" );
BOOST_ASSERT( !this->is_null( n ) );
return (*this)[n];
}
const_reference at( size_type n ) const
{
BOOST_PTR_CONTAINER_THROW_EXCEPTION( n >= this->size(), bad_index,
"'at()' out of bounds" );
BOOST_ASSERT( !this->is_null( n ) );
return (*this)[n];
}
public: // vector interface
size_type capacity() const
{
return this->base().capacity();
}
void reserve( size_type n )
{
this->base().reserve( n );
}
void reverse()
{
this->base().reverse();
}
public: // assign, insert, transfer
// overhead: 1 heap allocation (very cheap compared to cloning)
template< class InputIterator >
void assign( InputIterator first, InputIterator last ) // strong
{
base_type temp( first, last );
this->swap( temp );
}
template< class Range >
void assign( const Range& r ) // strong
{
assign( boost::begin(r), boost::end(r ) );
}
private:
template< class I >
void insert_impl( iterator before, I first, I last, std::input_iterator_tag ) // strong
{
ptr_sequence_adapter temp(first,last); // strong
transfer( before, temp ); // strong, commit
}
template< class I >
void insert_impl( iterator before, I first, I last, std::forward_iterator_tag ) // strong
{
if( first == last )
return;
scoped_deleter sd( first, last ); // strong
this->insert_clones_and_release( sd, before ); // strong, commit
}
public:
using base_type::insert;
template< class InputIterator >
void insert( iterator before, InputIterator first, InputIterator last ) // strong
{
insert_impl( before, first, last, BOOST_DEDUCED_TYPENAME
iterator_category<InputIterator>::type() );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( iterator before, const Range& r )
{
insert( before, boost::begin(r), boost::end(r) );
}
#endif
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator last,
PtrSeqAdapter& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
this->base().
insert( before.base(), first.base(), last.base() ); // strong
from.base().erase( first.base(), last.base() ); // nothrow
}
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator object,
PtrSeqAdapter& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
this->base().insert( before.base(), *object.base() ); // strong
from.base().erase( object.base() ); // nothrow
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSeqAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator > >::type
transfer( iterator before, const Range& r, PtrSeqAdapter& from ) // strong
{
transfer( before, boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSeqAdapter >
void transfer( iterator before, PtrSeqAdapter& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
this->base().
insert( before.base(),
from.begin().base(), from.end().base() ); // strong
from.base().clear(); // nothrow
}
public: // C-array support
void transfer( iterator before, value_type* from,
size_type size, bool delete_from = true ) // strong
{
BOOST_ASSERT( from != 0 );
if( delete_from )
{
BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
deleter( from, size ); // nothrow
this->base().insert( before.base(), from, from + size ); // strong
deleter.release(); // nothrow
}
else
{
this->base().insert( before.base(), from, from + size ); // strong
}
}
value_type* c_array() // nothrow
{
if( this->empty() )
return 0;
T** res = reinterpret_cast<T**>( &this->begin().base()[0] );
return res;
}
public: // null functions
bool is_null( size_type idx ) const
{
BOOST_ASSERT( idx < this->size() );
return this->base()[idx] == 0;
}
public: // resize
void resize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void resize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
public: // algorithms
void sort( iterator first, iterator last )
{
sort( first, last, std::less<T>() );
}
void sort()
{
sort( this->begin(), this->end() );
}
template< class Compare >
void sort( iterator first, iterator last, Compare comp )
{
BOOST_ASSERT( first <= last && "out of range sort()" );
BOOST_ASSERT( this->begin() <= first && "out of range sort()" );
BOOST_ASSERT( last <= this->end() && "out of range sort()" );
// some static assert on the arguments of the comparison
std::sort( first.base(), last.base(),
void_ptr_indirect_fun<Compare,T>(comp) );
}
template< class Compare >
void sort( Compare comp )
{
sort( this->begin(), this->end(), comp );
}
void unique( iterator first, iterator last )
{
unique( first, last, std::equal_to<T>() );
}
void unique()
{
unique( this->begin(), this->end() );
}
private:
struct is_not_zero_ptr
{
template< class U >
bool operator()( const U* r ) const
{
return r != 0;
}
};
protected:
template< class Fun, class Arg1 >
class void_ptr_delete_if
{
Fun fun;
public:
void_ptr_delete_if() : fun(Fun())
{ }
void_ptr_delete_if( Fun f ) : fun(f)
{ }
bool operator()( void* r ) const
{
BOOST_ASSERT( r != 0 );
Arg1 arg1 = static_cast<Arg1>(r);
if( fun( *arg1 ) )
{
clone_allocator_type::deallocate_clone( arg1 );
return true;
}
return false;
}
};
private:
void compact_and_erase_nulls( iterator first, iterator last ) // nothrow
{
typename base_type::ptr_iterator p = std::stable_partition(
first.base(),
last.base(),
is_not_zero_ptr() );
this->base().erase( p, this->end().base() );
}
void range_check_impl( iterator first, iterator last,
std::bidirectional_iterator_tag )
{ /* do nothing */ }
void range_check_impl( iterator first, iterator last,
std::random_access_iterator_tag )
{
BOOST_ASSERT( first <= last && "out of range unique()/erase_if()" );
BOOST_ASSERT( this->begin() <= first && "out of range unique()/erase_if()" );
BOOST_ASSERT( last <= this->end() && "out of range unique()/erase_if)(" );
}
void range_check( iterator first, iterator last )
{
range_check_impl( first, last,
BOOST_DEDUCED_TYPENAME iterator_category<iterator>::type() );
}
public:
template< class Compare >
void unique( iterator first, iterator last, Compare comp )
{
range_check(first,last);
iterator prev = first;
iterator next = first;
++next;
for( ; next != last; ++next )
{
BOOST_ASSERT( !::boost::is_null(prev) );
BOOST_ASSERT( !::boost::is_null(next) );
if( comp( *prev, *next ) )
{
this->remove( next ); // delete object
*next.base() = 0; // mark pointer as deleted
}
else
{
prev = next;
}
// ++next
}
compact_and_erase_nulls( first, last );
}
template< class Compare >
void unique( Compare comp )
{
unique( this->begin(), this->end(), comp );
}
template< class Pred >
void erase_if( iterator first, iterator last, Pred pred )
{
range_check(first,last);
this->base().erase( std::remove_if( first.base(), last.base(),
void_ptr_delete_if<Pred,value_type>(pred) ),
last.base() );
}
template< class Pred >
void erase_if( Pred pred )
{
erase_if( this->begin(), this->end(), pred );
}
void merge( iterator first, iterator last,
ptr_sequence_adapter& from )
{
merge( first, last, from, std::less<T>() );
}
template< class BinPred >
void merge( iterator first, iterator last,
ptr_sequence_adapter& from, BinPred pred )
{
void_ptr_indirect_fun<BinPred,T> bin_pred(pred);
size_type current_size = this->size();
this->transfer( this->end(), first, last, from );
typename base_type::ptr_iterator middle = this->begin().base();
std::advance(middle,current_size);
std::inplace_merge( this->begin().base(),
middle,
this->end().base(),
bin_pred );
}
void merge( ptr_sequence_adapter& r )
{
merge( r, std::less<T>() );
BOOST_ASSERT( r.empty() );
}
template< class BinPred >
void merge( ptr_sequence_adapter& r, BinPred pred )
{
merge( r.begin(), r.end(), r, pred );
BOOST_ASSERT( r.empty() );
}
};
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,155 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_SET_HPP
#define BOOST_PTR_CONTAINER_PTR_SET_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/indirect_fun.hpp>
#include <boost/ptr_container/ptr_set_adapter.hpp>
#include <set>
namespace boost
{
template
<
class Key,
class Compare = std::less<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_set :
public ptr_set_adapter< Key,
std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
{
typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
base_type;
typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
public:
ptr_set()
{ }
explicit ptr_set( const Compare& comp,
const Allocator& a = Allocator() )
: base_type( comp, a )
{ }
template< typename InputIterator >
ptr_set( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_set( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_set,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_set, base_type )
};
template
<
class Key,
class Compare = std::less<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_multiset :
public ptr_multiset_adapter< Key,
std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
{
typedef ptr_multiset_adapter< Key,
std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
base_type;
typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
public:
ptr_multiset()
{ }
explicit ptr_multiset( const Compare& comp,
const Allocator& a = Allocator() )
: base_type( comp, a )
{ }
template< typename InputIterator >
ptr_multiset( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_multiset( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multiset,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_multiset,
base_type )
};
/////////////////////////////////////////////////////////////////////////
// clonability
template< typename K, typename C, typename CA, typename A >
inline ptr_set<K,C,CA,A>* new_clone( const ptr_set<K,C,CA,A>& r )
{
return r.clone().release();
}
template< typename K, typename C, typename CA, typename A >
inline ptr_multiset<K,C,CA,A>* new_clone( const ptr_multiset<K,C,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename K, typename C, typename CA, typename A >
inline void swap( ptr_set<K,C,CA,A>& l, ptr_set<K,C,CA,A>& r )
{
l.swap(r);
}
template< typename K, typename C, typename CA, typename A >
inline void swap( ptr_multiset<K,C,CA,A>& l, ptr_multiset<K,C,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,692 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_SET_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_PTR_SET_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#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/range/iterator_range.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class Key,
class VoidPtrSet,
bool Ordered
>
struct set_config
{
typedef VoidPtrSet
void_container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
allocator_type;
typedef Key value_type;
typedef value_type
key_type;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_value_compare<VoidPtrSet>,
mpl::identity<void> >::type
value_compare;
typedef value_compare
key_compare;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_hasher<VoidPtrSet> >::type
hasher;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_key_equal<VoidPtrSet> >::type
key_equal;
typedef BOOST_DEDUCED_TYPENAME
mpl::if_c<Ordered,
ordered_associative_container_tag,
unordered_associative_container_tag>::type
container_type;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSet::iterator, Key >
iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSet::const_iterator, const Key >
const_iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrSet>,
select_local_iterator<VoidPtrSet> >::type,
Key >
local_iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrSet>,
select_const_local_iterator<VoidPtrSet> >::type,
const Key >
const_local_iterator;
template< class Iter >
static Key* get_pointer( Iter i )
{
return static_cast<Key*>( *i.base() );
}
template< class Iter >
static const Key* get_const_pointer( Iter i )
{
return static_cast<const Key*>( *i.base() );
}
BOOST_STATIC_CONSTANT(bool, allow_null = false );
};
template
<
class Key,
class VoidPtrSet,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_set_adapter_base
: public ptr_container_detail::associative_ptr_container< set_config<Key,VoidPtrSet,Ordered>,
CloneAllocator >
{
typedef ptr_container_detail::associative_ptr_container< set_config<Key,VoidPtrSet,Ordered>,
CloneAllocator >
base_type;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
public:
ptr_set_adapter_base()
{ }
template< class SizeType >
ptr_set_adapter_base( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Compare, class Allocator >
ptr_set_adapter_base( const Compare& comp,
const Allocator& a )
: base_type( comp, a )
{ }
template< class Hash, class Pred, class Allocator >
ptr_set_adapter_base( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator, class Compare, class Allocator >
ptr_set_adapter_base( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a )
: base_type( first, last, comp, a )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_set_adapter_base( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class U, class Set, class CA, bool b >
ptr_set_adapter_base( const ptr_set_adapter_base<U,Set,CA,b>& r )
: base_type( r )
{ }
ptr_set_adapter_base( const ptr_set_adapter_base& r )
: base_type( r )
{ }
template< class PtrContainer >
explicit ptr_set_adapter_base( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
ptr_set_adapter_base& operator=( ptr_set_adapter_base r )
{
this->swap( r );
return *this;
}
template< typename PtrContainer >
ptr_set_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
{
base_type::operator=( clone );
return *this;
}
using base_type::erase;
size_type erase( const key_type& x ) // nothrow
{
key_type* key = const_cast<key_type*>(&x);
iterator i( this->base().find( key ) );
if( i == this->end() ) // nothrow
return 0u; // nothrow
key = static_cast<key_type*>(*i.base()); // nothrow
size_type res = this->base().erase( key ); // nothrow
this->remove( key ); // nothrow
return res;
}
iterator find( const key_type& x )
{
return iterator( this->base().
find( const_cast<key_type*>(&x) ) );
}
const_iterator find( const key_type& x ) const
{
return const_iterator( this->base().
find( const_cast<key_type*>(&x) ) );
}
size_type count( const key_type& x ) const
{
return this->base().count( const_cast<key_type*>(&x) );
}
iterator lower_bound( const key_type& x )
{
return iterator( this->base().
lower_bound( const_cast<key_type*>(&x) ) );
}
const_iterator lower_bound( const key_type& x ) const
{
return const_iterator( this->base().
lower_bound( const_cast<key_type*>(&x) ) );
}
iterator upper_bound( const key_type& x )
{
return iterator( this->base().
upper_bound( const_cast<key_type*>(&x) ) );
}
const_iterator upper_bound( const key_type& x ) const
{
return const_iterator( this->base().
upper_bound( const_cast<key_type*>(&x) ) );
}
iterator_range<iterator> equal_range( const key_type& x )
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator>
p = this->base().
equal_range( const_cast<key_type*>(&x) );
return make_iterator_range( iterator( p.first ),
iterator( p.second ) );
}
iterator_range<const_iterator> equal_range( const key_type& x ) const
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator>
p = this->base().
equal_range( const_cast<key_type*>(&x) );
return make_iterator_range( const_iterator( p.first ),
const_iterator( p.second ) );
}
protected:
size_type bucket( const key_type& key ) const
{
return this->base().bucket( const_cast<key_type*>(&key) );
}
};
} // ptr_container_detail
/////////////////////////////////////////////////////////////////////////
// ptr_set_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class Key,
class VoidPtrSet,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_set_adapter :
public ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrSet,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrSet,CloneAllocator,Ordered>
base_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
allocator_type;
private:
template< typename II >
void set_basic_clone_and_insert( II first, II last ) // basic
{
while( first != last )
{
if( this->find( *first ) == this->end() )
insert( CloneAllocator::allocate_clone( *first ) ); // strong, commit
++first;
}
}
public:
ptr_set_adapter()
{ }
template< class SizeType >
ptr_set_adapter( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Comp >
explicit ptr_set_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a )
{
BOOST_ASSERT( this->empty() );
}
template< class Hash, class Pred, class Allocator >
ptr_set_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_set_adapter( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Compare, class Allocator >
ptr_set_adapter( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator a = Allocator() )
: base_type( comp, a )
{
BOOST_ASSERT( this->empty() );
set_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_set_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
explicit ptr_set_adapter( const ptr_set_adapter& r )
: base_type( r )
{ }
template< class U, class Set, class CA, bool b >
explicit ptr_set_adapter( const ptr_set_adapter<U,Set,CA,b>& r )
: base_type( r )
{ }
template< class PtrContainer >
explicit ptr_set_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
template< class U, class Set, class CA, bool b >
ptr_set_adapter& operator=( const ptr_set_adapter<U,Set,CA,b>& r )
{
base_type::operator=( r );
return *this;
}
template< class T >
void operator=( std::auto_ptr<T> r )
{
base_type::operator=( r );
}
std::pair<iterator,bool> insert( key_type* x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" );
auto_type ptr( x );
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
res = this->base().insert( x );
if( res.second )
ptr.release();
return std::make_pair( iterator( res.first ), res.second );
}
template< class U >
std::pair<iterator,bool> insert( std::auto_ptr<U> x )
{
return insert( x.release() );
}
iterator insert( iterator where, key_type* x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" );
auto_type ptr( x );
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( where.base(), x );
if( *res == x )
ptr.release();
return iterator( res);
}
template< class U >
iterator insert( iterator where, std::auto_ptr<U> x )
{
return insert( where, x.release() );
}
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
set_basic_clone_and_insert( first, last );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
#endif
template< class PtrSetAdapter >
bool transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator object,
PtrSetAdapter& from ) // strong
{
return this->single_transfer( object, from );
}
template< class PtrSetAdapter >
size_type
transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator last,
PtrSetAdapter& from ) // basic
{
return this->single_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSetAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator >,
size_type >::type
transfer( const Range& r, PtrSetAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSetAdapter >
size_type transfer( PtrSetAdapter& from ) // basic
{
return transfer( from.begin(), from.end(), from );
}
};
/////////////////////////////////////////////////////////////////////////
// ptr_multiset_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class Key,
class VoidPtrMultiSet,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_multiset_adapter :
public ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrMultiSet,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrMultiSet,CloneAllocator,Ordered> base_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiSet::allocator_type
allocator_type;
private:
template< typename II >
void set_basic_clone_and_insert( II first, II last ) // basic
{
while( first != last )
{
insert( CloneAllocator::allocate_clone( *first ) ); // strong, commit
++first;
}
}
public:
ptr_multiset_adapter()
{ }
template< class SizeType >
ptr_multiset_adapter( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Comp >
explicit ptr_multiset_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a )
{ }
template< class Hash, class Pred, class Allocator >
ptr_multiset_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_multiset_adapter( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Comp >
ptr_multiset_adapter( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( comp, a )
{
set_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_multiset_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class U, class Set, class CA, bool b >
explicit ptr_multiset_adapter( const ptr_multiset_adapter<U,Set,CA,b>& r )
: base_type( r )
{ }
template< class PtrContainer >
explicit ptr_multiset_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
template< class U, class Set, class CA, bool b >
ptr_multiset_adapter& operator=( const ptr_multiset_adapter<U,Set,CA,b>& r )
{
base_type::operator=( r );
return *this;
}
template< class T >
void operator=( std::auto_ptr<T> r )
{
base_type::operator=( r );
}
iterator insert( iterator before, key_type* x ) // strong
{
return base_type::insert( before, x );
}
template< class U >
iterator insert( iterator before, std::auto_ptr<U> x )
{
return insert( before, x.release() );
}
iterator insert( key_type* x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'ptr_multiset::insert()'" );
auto_type ptr( x );
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( x );
ptr.release();
return iterator( res );
}
template< class U >
iterator insert( std::auto_ptr<U> x )
{
return insert( x.release() );
}
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
set_basic_clone_and_insert( first, last );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
#endif
template< class PtrSetAdapter >
void transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator object,
PtrSetAdapter& from ) // strong
{
this->multi_transfer( object, from );
}
template< class PtrSetAdapter >
size_type transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator last,
PtrSetAdapter& from ) // basic
{
return this->multi_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSetAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator >, size_type >::type
transfer( const Range& r, PtrSetAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSetAdapter >
void transfer( PtrSetAdapter& from ) // basic
{
transfer( from.begin(), from.end(), from );
BOOST_ASSERT( from.empty() );
}
};
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,248 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
#define BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/unordered_map.hpp>
#include <boost/ptr_container/ptr_map_adapter.hpp>
namespace boost
{
template
<
class Key,
class T,
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 ptr_unordered_map :
public ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
{
typedef ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
base_type;
typedef ptr_unordered_map<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_map()
{ }
explicit ptr_unordered_map( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_map( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_map( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_map( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_map,
base_type,
this_type )
template< class U >
ptr_unordered_map( const ptr_unordered_map<Key,U>& r ) : base_type( r )
{ }
ptr_unordered_map& operator=( ptr_unordered_map r )
{
this->swap( r );
return *this;
}
};
template
<
class Key,
class T,
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 ptr_unordered_multimap :
public ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
{
typedef ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
base_type;
typedef ptr_unordered_multimap<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_multimap()
{ }
explicit ptr_unordered_multimap( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_multimap( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_multimap( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_multimap( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multimap,
base_type,
this_type )
template< class U >
ptr_unordered_multimap( const ptr_unordered_multimap<Key,U>& r ) : base_type( r )
{ }
ptr_unordered_multimap& operator=( ptr_unordered_multimap r )
{
this->swap( r );
return *this;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< class K, class T, class H, class P, class CA, class A >
inline ptr_unordered_map<K,T,H,P,CA,A>*
new_clone( const ptr_unordered_map<K,T,H,P,CA,A>& r )
{
return r.clone().release();
}
template< class K, class T, class H, class P, class CA, class A >
inline ptr_unordered_multimap<K,T,H,P,CA,A>*
new_clone( const ptr_unordered_multimap<K,T,H,P,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< class K, class T, class H, class P, class CA, class A >
inline void swap( ptr_unordered_map<K,T,H,P,CA,A>& l,
ptr_unordered_map<K,T,H,P,CA,A>& r )
{
l.swap(r);
}
template< class K, class T, class H, class P, class CA, class A >
inline void swap( ptr_unordered_multimap<K,T,H,P,CA,A>& l,
ptr_unordered_multimap<K,T,H,P,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,240 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
#define BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/indirect_fun.hpp>
#include <boost/ptr_container/ptr_set_adapter.hpp>
#include <boost/unordered_set.hpp>
namespace boost
{
template
<
class Key,
class Hash = boost::hash<Key>,
class Pred = std::equal_to<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
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>,
CloneAllocator, false >
{
typedef ptr_set_adapter< Key,
boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
base_type;
typedef ptr_unordered_set<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_set()
{}
explicit ptr_unordered_set( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_set( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_set( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_set( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_set,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_set,
base_type )
};
template
<
class Key,
class Hash = boost::hash<Key>,
class Pred = std::equal_to<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_unordered_multiset :
public ptr_multiset_adapter< Key,
boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
{
typedef ptr_multiset_adapter< Key,
boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
base_type;
typedef ptr_unordered_multiset<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_multiset()
{ }
explicit ptr_unordered_multiset( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_multiset( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_multiset( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_multiset( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multiset,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_multiset,
base_type )
};
/////////////////////////////////////////////////////////////////////////
// clonability
template< typename K, typename H, typename P, typename CA, typename A >
inline ptr_unordered_set<K,H,P,CA,A>*
new_clone( const ptr_unordered_set<K,H,P,CA,A>& r )
{
return r.clone().release();
}
template< typename K, typename H, typename P, typename CA, typename A >
inline ptr_unordered_multiset<K,H,P,CA,A>*
new_clone( const ptr_unordered_multiset<K,H,P,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename K, typename H, typename P, typename CA, typename A >
inline void swap( ptr_unordered_set<K,H,P,CA,A>& l,
ptr_unordered_set<K,H,P,CA,A>& r )
{
l.swap(r);
}
template< typename K, typename H, typename P, typename CA, typename A >
inline void swap( ptr_unordered_multiset<K,H,P,CA,A>& l,
ptr_unordered_multiset<K,H,P,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,77 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_VECTOR_HPP
#define BOOST_PTR_CONTAINER_PTR_VECTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <vector>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_vector : public
ptr_sequence_adapter< T,
std::vector<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
std::vector<void*,Allocator>,
CloneAllocator >
base_class;
typedef ptr_vector<T,CloneAllocator,Allocator> this_type;
public:
BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_vector,
base_class,
this_type )
explicit ptr_vector( size_type n,
const allocator_type& alloc = allocator_type() )
: base_class(alloc)
{
this->base().reserve( n );
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_vector<T,CA,A>* new_clone( const ptr_vector<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_vector<T,CA,A>& l, ptr_vector<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@@ -0,0 +1,47 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_array.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, std::size_t N, class CloneAllocator>
void save(Archive& ar, const ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/)
{
ptr_container_detail::save_helper(ar, c);
}
template<class Archive, class T, std::size_t N, class CloneAllocator>
void load(Archive& ar, ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/)
{
typedef ptr_array<T, N, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
for(size_type i = 0u; i != N; ++i)
{
T* p;
ar >> boost::serialization::make_nvp( ptr_container_detail::item(), p );
c.replace(i, p);
}
}
template<class Archive, class T, std::size_t N, class CloneAllocator>
void serialize(Archive& ar, ptr_array<T, N, CloneAllocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,46 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_CIRCULAR_BUFFER_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_CIRCULAR_BUFFER_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_circular_buffer.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void load(Archive& ar, ptr_circular_buffer<T, CloneAllocator, Allocator>& c, unsigned int version)
{
typedef ptr_circular_buffer<T, CloneAllocator, Allocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
c.reserve(n);
ptr_container_detail::load_helper(ar, c, n);
}
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_circular_buffer<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,19 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_HPP
#include <boost/ptr_container/serialize_ptr_array.hpp>
#include <boost/ptr_container/serialize_ptr_deque.hpp>
#include <boost/ptr_container/serialize_ptr_list.hpp>
#include <boost/ptr_container/serialize_ptr_map.hpp>
#include <boost/ptr_container/serialize_ptr_set.hpp>
#include <boost/ptr_container/serialize_ptr_vector.hpp>
#include <boost/ptr_container/serialize_ptr_unordered_set.hpp>
#include <boost/ptr_container/serialize_ptr_unordered_map.hpp>
#include <boost/ptr_container/serialize_ptr_circular_buffer.hpp>
#endif

View File

@@ -0,0 +1,27 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_DEQUE_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_DEQUE_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_deque.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_deque<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,27 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_LIST_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_LIST_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_list.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_list<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,33 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_MAP_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_MAP_HPP
#include <boost/ptr_container/detail/serialize_ptr_map_adapter.hpp>
#include <boost/ptr_container/ptr_map.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class Key, class T, class Compare, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_map<Key, T, Compare, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class Key, class T, class Compare, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_multimap<Key, T, Compare, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,33 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_SET_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_SET_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_set.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_set<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_multiset<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,39 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_UNORDERED_PTR_MAP_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_UNORDERED_PTR_MAP_HPP
#include <boost/ptr_container/detail/serialize_ptr_map_adapter.hpp>
#include <boost/ptr_container/ptr_unordered_map.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class Key, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_map<Key, T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class Key, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_multimap<Key, T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,39 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_UNORDERED_SET_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_UNORDERED_SET_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_unordered_set.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_set<T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_multiset<T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,40 @@
// Copyright Sebastian Ramacher, 2007.
// 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)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_VECTOR_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_VECTOR_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void load(Archive& ar, ptr_vector<T, CloneAllocator, Allocator>& c, unsigned int /*version*/)
{
typedef ptr_vector<T, CloneAllocator, Allocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
c.reserve(n);
ptr_container_detail::load_helper(ar, c, n);
}
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_vector<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif