|
Boost-Commit : |
From: nesotto_at_[hidden]
Date: 2008-06-04 11:30:17
Author: nesotto
Date: 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
New Revision: 46117
URL: http://svn.boost.org/trac/boost/changeset/46117
Log:
Update for unordered containers
Added:
trunk/boost/ptr_container/serialize_ptr_unordered_map.hpp (contents, props changed)
trunk/boost/ptr_container/serialize_ptr_unordered_set.hpp (contents, props changed)
Binary files modified:
trunk/boost/ptr_container/serialize_ptr_container.hpp
Text files modified:
trunk/boost/ptr_container/detail/associative_ptr_container.hpp | 130 +++++++++++++++++++++++--
trunk/boost/ptr_container/detail/meta_functions.hpp | 18 +++
trunk/boost/ptr_container/detail/reversible_ptr_container.hpp | 34 +++++-
trunk/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp | 18 +-
trunk/boost/ptr_container/ptr_container.hpp | 5
trunk/boost/ptr_container/ptr_map.hpp | 24 ++++
trunk/boost/ptr_container/ptr_map_adapter.hpp | 199 ++++++++++++++++++++++++++++++---------
trunk/boost/ptr_container/ptr_sequence_adapter.hpp | 33 ++----
trunk/boost/ptr_container/ptr_set.hpp | 36 +++++--
trunk/boost/ptr_container/ptr_set_adapter.hpp | 94 +++++++++++++-----
trunk/boost/ptr_container/ptr_unordered_set.hpp | 98 ++++++++++++++++---
11 files changed, 534 insertions(+), 155 deletions(-)
Modified: trunk/boost/ptr_container/detail/associative_ptr_container.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/associative_ptr_container.hpp (original)
+++ trunk/boost/ptr_container/detail/associative_ptr_container.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -55,6 +55,10 @@
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;
@@ -79,12 +83,17 @@
const Allocator& a )
: base_type( hash, pred, a )
{ }
-
+
+ template< class InputIterator >
+ associative_ptr_container( InputIterator first, InputIterator last )
+ : base_type( first, last, container_type() )
+ { }
+
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 )
+ : base_type( first, last, comp, a, container_type() )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
@@ -142,16 +151,6 @@
return this->base().value_comp();
}
- hasher hash_function() const
- {
- return this->base().hash_function();
- }
-
- key_equal key_eq() const
- {
- return this->base().key_eq();
- }
-
iterator erase( iterator before ) // nothrow
{
BOOST_ASSERT( !this->empty() );
@@ -272,6 +271,113 @@
}
return res;
}
+
+ reference front()
+ {
+ BOOST_ASSERT( !this->empty() );
+ BOOST_ASSERT( !::boost::is_null( this->begin() ) );
+ return *this->begin();
+ }
+
+ const_reference front() const
+ {
+ return const_cast<associative_ptr_container*>(this)->front();
+ }
+
+ reference back()
+ {
+ BOOST_ASSERT( !this->empty() );
+ BOOST_ASSERT( !::boost::is_null( --this->end() ) );
+ 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:
+ using base_type::begin;
+ using base_type::end;
+ using base_type::cbegin;
+ using base_type::cend;
+
+ 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'
Modified: trunk/boost/ptr_container/detail/meta_functions.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/meta_functions.hpp (original)
+++ trunk/boost/ptr_container/detail/meta_functions.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -42,6 +42,24 @@
{
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;
+ };
}
}
Modified: trunk/boost/ptr_container/detail/reversible_ptr_container.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/reversible_ptr_container.hpp (original)
+++ trunk/boost/ptr_container/detail/reversible_ptr_container.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -415,11 +415,7 @@
const allocator_type& a )
: c_( hash, pred, a )
{
- if( first == last )
- return;
-
- scoped_deleter sd( first, last );
- insert_clones_and_release( sd );
+ associative_constructor_impl( first, last );
}
public:
@@ -453,7 +449,17 @@
{ 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_ );
@@ -656,8 +662,17 @@
#define BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type ) \
\
template< class U > \
+ explicit PC( const PC& r ) : base_type( r ) { } \
+ \
+ template< class U > \
explicit PC( const PC<U>& r ) : base_type( r ) { } \
\
+ PC& operator=( const PC& r ) \
+ { \
+ base_type::operator=( r ); \
+ return *this; \
+ } \
+ \
template< class U > \
PC& operator=( const PC<U>& r ) \
{ \
@@ -671,10 +686,13 @@
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; \
- explicit PC( const allocator_type& a = allocator_type() ) : base_type(a) {} \
+ 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 = allocator_type() ) : base_type( first, last, a ) {}
+ 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 ) \
Modified: trunk/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp (original)
+++ trunk/boost/ptr_container/detail/serialize_ptr_map_adapter.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -16,10 +16,10 @@
namespace serialization
{
-template<class Archive, class T, class VoidPtrMap, class CloneAllocator>
-void save(Archive& ar, const ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator>& c, unsigned int version)
+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> container;
+ 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(),
@@ -34,10 +34,10 @@
}
}
-template<class Archive, class T, class VoidPtrMap, class CloneAllocator>
-void load(Archive& ar, ptr_map_adapter<T, VoidPtrMap, CloneAllocator>& c, unsigned int version)
+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> container;
+ 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;
@@ -57,10 +57,10 @@
}
}
-template<class Archive, class T, class VoidPtrMap, class CloneAllocator>
-void load(Archive& ar, ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator>& c, unsigned int version)
+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> container;
+ 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;
Modified: trunk/boost/ptr_container/ptr_container.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_container.hpp (original)
+++ trunk/boost/ptr_container/ptr_container.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -1,7 +1,7 @@
//
// Boost.Pointer Container
//
-// Copyright Thorsten Ottosen 2003-2005. Use, modification and
+// 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)
@@ -22,6 +22,9 @@
#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_inserter.hpp>
#endif
Modified: trunk/boost/ptr_container/ptr_map.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_map.hpp (original)
+++ trunk/boost/ptr_container/ptr_map.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -41,13 +41,21 @@
typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
public:
- explicit ptr_map( const Compare& comp = Compare(),
+ 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 = Compare(),
+ const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
@@ -88,13 +96,21 @@
typedef ptr_multimap<Key,T,Compare,CloneAllocator,Allocator> this_type;
public:
- explicit ptr_multimap( const Compare& comp = Compare(),
+ 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 = Compare(),
+ const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
Modified: trunk/boost/ptr_container/ptr_map_adapter.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_map_adapter.hpp (original)
+++ trunk/boost/ptr_container/ptr_map_adapter.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -31,7 +31,7 @@
<
class T,
class VoidPtrMap,
- bool Ordered = true
+ bool Ordered
>
struct map_config
{
@@ -83,7 +83,23 @@
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 )
{
@@ -105,19 +121,19 @@
<
class T,
class VoidPtrMap,
- class CloneAllocator
+ class CloneAllocator,
+ bool Ordered
>
class ptr_map_adapter_base :
- public ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap>,
+ public ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap,Ordered>,
CloneAllocator >
{
- typedef ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap>,
+ typedef ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap,Ordered>,
CloneAllocator >
base_type;
- typedef map_config<T,VoidPtrMap> config;
-
- typedef ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator> this_type;
+ typedef map_config<T,VoidPtrMap,Ordered> config;
+ typedef ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered> this_type;
public:
@@ -200,18 +216,48 @@
public:
- template< class InputIterator >
- ptr_map_adapter_base( InputIterator first, InputIterator last,
- const allocator_type& a = allocator_type() )
- : base_type( first, last, a )
+ 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 )
+ const allocator_type& 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 )
@@ -313,6 +359,12 @@
{
return replace( where, x.release() );
}
+
+ protected:
+ size_type bucket( const key_type& key ) const
+ {
+ return this->base().bucket( key );
+ }
};
} // ptr_container_detail
@@ -325,12 +377,13 @@
<
class T,
class VoidPtrMap,
- class CloneAllocator = heap_clone_allocator
+ class CloneAllocator = heap_clone_allocator,
+ bool Ordered = true
>
class ptr_map_adapter :
- public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator>
+ public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>
{
- typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator>
+ typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>
base_type;
public:
@@ -346,8 +399,6 @@
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
- typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::key_compare
- key_compare;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
@@ -382,29 +433,53 @@
}
public:
+ ptr_map_adapter( )
+ { }
- explicit ptr_map_adapter( const key_compare& comp = key_compare(),
- const allocator_type& a = allocator_type() )
+ 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 key_compare& comp = key_compare(),
+ 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 );
+ }
+
explicit ptr_map_adapter( const ptr_map_adapter& r )
- : base_type( key_compare(), allocator_type() )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
- template< class Key, class U >
- explicit ptr_map_adapter( const ptr_map_adapter<Key,U>& r )
- : base_type( key_compare(), allocator_type() )
+ template< class Key, class U, class CA, bool b >
+ explicit ptr_map_adapter( const ptr_map_adapter<Key,U,CA,b>& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
@@ -420,8 +495,8 @@
return *this;
}
- template< class Key, class U >
- ptr_map_adapter& operator=( const ptr_map_adapter<Key,U>& r )
+ template< class Key, class U, class CA, bool b >
+ ptr_map_adapter& operator=( const ptr_map_adapter<Key,U,CA,b>& r )
{
ptr_map_adapter clone( r );
this->swap( clone );
@@ -558,12 +633,13 @@
<
class T,
class VoidPtrMultiMap,
- class CloneAllocator = heap_clone_allocator
+ class CloneAllocator = heap_clone_allocator,
+ bool Ordered = true
>
class ptr_multimap_adapter :
- public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator>
+ public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator,Ordered>
{
- typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator>
+ typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator,Ordered>
base_type;
public: // typedefs
@@ -581,8 +657,6 @@
mapped_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
- typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiMap::key_compare
- key_compare;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiMap::allocator_type
allocator_type;
private:
@@ -610,29 +684,60 @@
}
public:
-
- explicit ptr_multimap_adapter( const key_compare& comp = key_compare(),
- const allocator_type& a = allocator_type() )
+
+ 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 key_compare& comp = key_compare(),
- const allocator_type& a = allocator_type() )
+ 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 );
+ }
+
explicit ptr_multimap_adapter( const ptr_multimap_adapter& r )
- : base_type( key_compare(), allocator_type() )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
- template< class Key, class U >
- explicit ptr_multimap_adapter( const ptr_multimap_adapter<Key,U>& r )
- : base_type( key_compare(), allocator_type() )
+ template< class Key, class U, class CA, bool b >
+ explicit ptr_multimap_adapter( const ptr_multimap_adapter<Key,U,CA,b>& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
@@ -648,8 +753,8 @@
return *this;
}
- template< class Key, class U >
- ptr_multimap_adapter& operator=( const ptr_multimap_adapter<Key,U>& r )
+ template< class Key, class U, class CA, bool b >
+ ptr_multimap_adapter& operator=( const ptr_multimap_adapter<Key,U,CA,b>& r )
{
ptr_multimap_adapter clone( r );
this->swap( clone );
Modified: trunk/boost/ptr_container/ptr_sequence_adapter.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_sequence_adapter.hpp (original)
+++ trunk/boost/ptr_container/ptr_sequence_adapter.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -209,9 +209,8 @@
auto_type pop_back()
{
- BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
- bad_ptr_container_operation,
- "'pop_back()' on empty container" );
+ 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
@@ -220,9 +219,8 @@
auto_type pop_front()
{
- BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
- bad_ptr_container_operation,
- "'pop_front()' on empty container" );
+ 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
@@ -231,38 +229,29 @@
reference front()
{
- BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
- bad_ptr_container_operation,
- "accessing 'front()' on empty container" );
+ BOOST_ASSERT( !this->empty() &&
+ "accessing 'front()' on empty container" );
+
BOOST_ASSERT( !::boost::is_null( this->begin() ) );
return *this->begin();
}
const_reference front() const
{
- BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
- bad_ptr_container_operation,
- "accessing 'front()' on empty container" );
- BOOST_ASSERT( !::boost::is_null( this->begin() ) );
- return *this->begin();
+ return const_cast<ptr_sequence_adapter*>(this)->front();
}
reference back()
{
- BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
- bad_ptr_container_operation,
- "accessing 'back()' on empty container" );
+ BOOST_ASSERT( !this->empty() &&
+ "accessing 'back()' on empty container" );
BOOST_ASSERT( !::boost::is_null( --this->end() ) );
return *--this->end();
}
const_reference back() const
{
- BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
- bad_ptr_container_operation,
- "accessing 'back()' on empty container" );
- BOOST_ASSERT( !::boost::is_null( --this->end() ) );
- return *--this->end();
+ return const_cast<ptr_sequence_adapter*>(this)->back();
}
public: // deque/vector inerface
Modified: trunk/boost/ptr_container/ptr_set.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_set.hpp (original)
+++ trunk/boost/ptr_container/ptr_set.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -33,23 +33,31 @@
class ptr_set :
public ptr_set_adapter< Key,
std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
- CloneAllocator >
+ CloneAllocator, true >
{
typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
- CloneAllocator >
+ CloneAllocator, true >
base_type;
typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
public:
- explicit ptr_set( const Compare& comp = Compare(),
+ 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 = Compare(),
+ const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
@@ -73,23 +81,31 @@
class ptr_multiset :
public ptr_multiset_adapter< Key,
std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
- CloneAllocator >
+ CloneAllocator, true >
{
typedef ptr_multiset_adapter< Key,
std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
- CloneAllocator >
+ CloneAllocator, true >
base_type;
typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
public:
- explicit ptr_multiset( const Compare& comp = Compare(),
+ 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 = Compare(),
+ const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
Modified: trunk/boost/ptr_container/ptr_set_adapter.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_set_adapter.hpp (original)
+++ trunk/boost/ptr_container/ptr_set_adapter.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -29,7 +29,7 @@
<
class Key,
class VoidPtrSet,
- bool Ordered = true
+ bool Ordered
>
struct set_config
{
@@ -67,8 +67,8 @@
typedef BOOST_DEDUCED_TYPENAME
mpl::if_c<Ordered,
- ptr_container_detail::ordered_associative_container_tag,
- ptr_container_detail::unordered_associative_container_tag>::type
+ ordered_associative_container_tag,
+ unordered_associative_container_tag>::type
container_type;
typedef void_ptr_iterator<
@@ -79,6 +79,22 @@
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 )
{
@@ -141,7 +157,12 @@
const Allocator& a )
: base_type( hash, pred, a )
{ }
-
+
+ template< class InputIterator >
+ ptr_set_adapter_base( InputIterator first, InputIterator last )
+ : base_type( first, last )
+ { }
+
template< class InputIterator, class Compare, class Allocator >
ptr_set_adapter_base( InputIterator first, InputIterator last,
const Compare& comp,
@@ -157,18 +178,22 @@
: base_type( first, last, hash, pred, a )
{ }
- template< class U, class Set >
- explicit ptr_set_adapter_base( const ptr_set_adapter_base<U,Set>& r )
+ template< class U, class Set, class CA, bool b >
+ explicit ptr_set_adapter_base( const ptr_set_adapter_base<U,Set,CA,b>& r )
: base_type( r )
{ }
-
+
+ explicit 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 )
{ }
- template< class U, class Set >
- ptr_set_adapter_base& operator=( const ptr_set_adapter_base<U,Set>& r )
+ template< class U, class Set, class CA, bool b >
+ ptr_set_adapter_base& operator=( const ptr_set_adapter_base<U,Set,CA,b>& r )
{
base_type::operator=( r );
return *this;
@@ -253,8 +278,13 @@
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
@@ -287,8 +317,6 @@
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
- typedef BOOST_DEDUCED_TYPENAME base_type::key_compare
- key_compare;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
allocator_type;
private:
@@ -328,10 +356,15 @@
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 = Compare(),
+ const Compare& comp,
const Allocator a = Allocator() )
: base_type( comp, a )
{
@@ -346,9 +379,13 @@
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
-
- template< class U, class Set >
- explicit ptr_set_adapter( const ptr_set_adapter<U,Set>& r )
+
+ 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 )
{ }
@@ -357,8 +394,8 @@
: base_type( clone )
{ }
- template< class U, class Set >
- ptr_set_adapter& operator=( const ptr_set_adapter<U,Set>& r )
+ 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;
@@ -489,8 +526,6 @@
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
- typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiSet::key_compare
- key_compare;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiSet::allocator_type
allocator_type;
private:
@@ -526,10 +561,15 @@
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 key_compare& comp = key_compare(),
+ const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( comp, a )
{
@@ -544,8 +584,8 @@
: base_type( first, last, hash, pred, a )
{ }
- template< class U, class Set >
- explicit ptr_multiset_adapter( const ptr_multiset_adapter<U,Set>& r )
+ 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 )
{ }
@@ -554,8 +594,8 @@
: base_type( clone )
{ }
- template< class U, class Set >
- ptr_multiset_adapter& operator=( const ptr_multiset_adapter<U,Set>& r )
+ 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;
Modified: trunk/boost/ptr_container/ptr_unordered_set.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_unordered_set.hpp (original)
+++ trunk/boost/ptr_container/ptr_unordered_set.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -47,6 +47,33 @@
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()
@@ -63,12 +90,14 @@
: base_type( n, comp, pred, a )
{ }
- // @todo: add const with two iterator arguments, and use
- // tags to by-pass default arguments
-
+ 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 = Hash(),
+ const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
@@ -92,12 +121,12 @@
class Allocator = std::allocator<void*>
>
class ptr_unordered_multiset :
- public ptr_set_adapter< Key,
+ 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_set_adapter< Key,
+ typedef ptr_multiset_adapter< Key,
boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
@@ -106,8 +135,38 @@
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() )
{ }
@@ -120,8 +179,13 @@
{ }
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 = Hash(),
+ const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
@@ -138,14 +202,16 @@
/////////////////////////////////////////////////////////////////////////
// clonability
- template< typename K, typename C, typename CA, typename A >
- inline ptr_unordered_set<K,C,CA,A>* new_clone( const ptr_unordered_set<K,C,CA,A>& r )
+ 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 C, typename CA, typename A >
- inline ptr_unordered_multiset<K,C,CA,A>* new_clone( const ptr_unordered_multiset<K,C,CA,A>& r )
+ 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();
}
@@ -153,14 +219,16 @@
/////////////////////////////////////////////////////////////////////////
// swap
- template< typename K, typename C, typename CA, typename A >
- inline void swap( ptr_unordered_set<K,C,CA,A>& l, ptr_unordered_set<K,C,CA,A>& r )
+ 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 C, typename CA, typename A >
- inline void swap( ptr_unordered_multiset<K,C,CA,A>& l, ptr_unordered_multiset<K,C,CA,A>& 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);
}
Modified: trunk/boost/ptr_container/serialize_ptr_container.hpp
==============================================================================
Binary files. No diff available.
Added: trunk/boost/ptr_container/serialize_ptr_unordered_map.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/ptr_container/serialize_ptr_unordered_map.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -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
Added: trunk/boost/ptr_container/serialize_ptr_unordered_set.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/ptr_container/serialize_ptr_unordered_set.hpp 2008-06-04 11:30:16 EDT (Wed, 04 Jun 2008)
@@ -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
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk