|
Boost-Commit : |
From: nesotto_at_[hidden]
Date: 2007-10-27 17:52:14
Author: nesotto
Date: 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
New Revision: 40512
URL: http://svn.boost.org/trac/boost/changeset/40512
Log:
minor change to scoped_deleter, some cleanup of explicit, and fixed a bug in assignment of ptr_maps
Text files modified:
trunk/boost/ptr_container/detail/associative_ptr_container.hpp | 6 +++---
trunk/boost/ptr_container/detail/reversible_ptr_container.hpp | 10 +++++-----
trunk/boost/ptr_container/detail/scoped_deleter.hpp | 12 +++++++++---
trunk/boost/ptr_container/ptr_array.hpp | 6 +++---
trunk/boost/ptr_container/ptr_map.hpp | 4 ++--
trunk/boost/ptr_container/ptr_map_adapter.hpp | 33 ++++++++++++++++++---------------
trunk/boost/ptr_container/ptr_sequence_adapter.hpp | 21 ++++++++++++++-------
trunk/boost/ptr_container/ptr_set_adapter.hpp | 26 +++++++++++++-------------
trunk/boost/ptr_container/ptr_vector.hpp | 4 ++--
9 files changed, 69 insertions(+), 53 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 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -68,17 +68,17 @@
{ }
template< class PtrContainer >
- associative_ptr_container( std::auto_ptr<PtrContainer> r )
+ explicit associative_ptr_container( std::auto_ptr<PtrContainer> r )
: base_type( r, key_compare() )
{ }
- associative_ptr_container( const associative_ptr_container& r )
+ explicit associative_ptr_container( const associative_ptr_container& r )
: base_type( r.begin(), r.end(), key_compare(),
BOOST_DEDUCED_TYPENAME Config::allocator_type() )
{ }
template< class C, class V >
- associative_ptr_container( const associative_ptr_container<C,V>& r )
+ explicit associative_ptr_container( const associative_ptr_container<C,V>& r )
: base_type( r.begin(), r.end(), key_compare(),
BOOST_DEDUCED_TYPENAME Config::allocator_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 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -286,7 +286,7 @@
}
public: // foundation! should be protected!
- explicit reversible_ptr_container( const allocator_type& a = allocator_type() )
+ reversible_ptr_container( const allocator_type& a = allocator_type() )
: c_( a )
{}
@@ -582,7 +582,7 @@
// is buggy on most compilers, so we use a macro instead
//
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type ) \
- PC( std::auto_ptr<this_type> r ) \
+ explicit PC( std::auto_ptr<this_type> r ) \
: base_type ( r ) { } \
\
PC& operator=( std::auto_ptr<this_type> r ) \
@@ -607,7 +607,7 @@
#define BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type ) \
\
template< class U > \
- PC( const PC<U>& r ) : base_type( r ) { } \
+ explicit PC( const PC<U>& r ) : base_type( r ) { } \
\
template< class U > \
PC& operator=( const PC<U>& r ) \
@@ -622,10 +622,10 @@
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( const allocator_type& a = allocator_type() ) : base_type(a) {} \
+ explicit PC( const allocator_type& a = allocator_type() ) : base_type(a) {} \
template< class InputIterator > \
PC( InputIterator first, InputIterator last, \
- const allocator_type& a = allocator_type() ) : base_type( first, last, a ) {}
+ const allocator_type& a = allocator_type() ) : 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/scoped_deleter.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/scoped_deleter.hpp (original)
+++ trunk/boost/ptr_container/detail/scoped_deleter.hpp 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -34,9 +34,15 @@
bool released_;
public:
- scoped_deleter( size_type size ) :
- ptrs_( new T*[size] ), stored_( 0 ),
- released_( false )
+ 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 );
}
Modified: trunk/boost/ptr_container/ptr_array.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_array.hpp (original)
+++ trunk/boost/ptr_container/ptr_array.hpp 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -83,7 +83,7 @@
ptr_array() : base_class()
{ }
- ptr_array( const ptr_array& r )
+ explicit ptr_array( const ptr_array& r )
{
size_t i = 0;
for( ; i != N; ++i )
@@ -92,7 +92,7 @@
}
template< class U >
- ptr_array( const ptr_array<U,N>& r )
+ explicit ptr_array( const ptr_array<U,N>& r )
{
size_t i = 0;
for( ; i != N; ++i )
@@ -100,7 +100,7 @@
static_cast<U*>( r.base()[i] ) );
}
- ptr_array( std::auto_ptr<this_type> r )
+ explicit ptr_array( std::auto_ptr<this_type> r )
: base_class( r ) { }
ptr_array& operator=( const ptr_array& r )
Modified: trunk/boost/ptr_container/ptr_map.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_map.hpp (original)
+++ trunk/boost/ptr_container/ptr_map.hpp 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -41,8 +41,8 @@
typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
public:
- ptr_map( const Compare& comp = Compare(),
- const Allocator& a = Allocator() )
+ explicit ptr_map( const Compare& comp = Compare(),
+ const Allocator& a = Allocator() )
: base_type( comp, a ) { }
template< class InputIterator >
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 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -181,20 +181,21 @@
{ }
template< class Compare, class Allocator >
- explicit ptr_map_adapter_base( const Compare& comp,
- const Allocator& a )
+ ptr_map_adapter_base( const Compare& comp,
+ const Allocator& a )
: base_type( comp, a )
{ }
-
+
template< class PtrContainer >
- ptr_map_adapter_base( std::auto_ptr<PtrContainer> clone )
+ explicit ptr_map_adapter_base( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
template< typename PtrContainer >
- void operator=( std::auto_ptr<PtrContainer> clone )
+ ptr_map_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
{
base_type::operator=( clone );
+ return *this;
}
iterator find( const key_type& x )
@@ -357,7 +358,7 @@
public:
explicit ptr_map_adapter( const key_compare& comp = key_compare(),
- const allocator_type& a = allocator_type() )
+ const allocator_type& a = allocator_type() )
: base_type( comp, a ) { }
template< class InputIterator >
@@ -369,14 +370,14 @@
map_basic_clone_and_insert( first, last );
}
- ptr_map_adapter( const ptr_map_adapter& r )
+ 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 >
- ptr_map_adapter( const ptr_map_adapter<Key,U>& r )
+ explicit ptr_map_adapter( const ptr_map_adapter<Key,U>& r )
: base_type( key_compare(), allocator_type() )
{
map_basic_clone_and_insert( r.begin(), r.end() );
@@ -394,7 +395,7 @@
}
template< class Key, class U >
- ptr_map_adapter& operator=( const ptr_map_adapter<Key,U> r )
+ ptr_map_adapter& operator=( const ptr_map_adapter<Key,U>& r )
{
ptr_map_adapter clone( r );
this->swap( clone );
@@ -402,9 +403,10 @@
}
template< class U >
- void operator=( std::auto_ptr<U> r )
+ ptr_map_adapter& operator=( std::auto_ptr<U> r )
{
base_type::operator=( r );
+ return *this;
}
using base_type::release;
@@ -557,21 +559,21 @@
map_basic_clone_and_insert( first, last );
}
- ptr_multimap_adapter( const ptr_multimap_adapter& r )
+ 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 >
- ptr_multimap_adapter( const ptr_multimap_adapter<Key,U>& r )
+ explicit ptr_multimap_adapter( const ptr_multimap_adapter<Key,U>& r )
: base_type( key_compare(), allocator_type() )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class U >
- ptr_multimap_adapter( std::auto_ptr<U> r ) : base_type( r )
+ explicit ptr_multimap_adapter( std::auto_ptr<U> r ) : base_type( r )
{ }
ptr_multimap_adapter& operator=( const ptr_multimap_adapter& r )
@@ -582,7 +584,7 @@
}
template< class Key, class U >
- ptr_multimap_adapter& operator=( const ptr_multimap_adapter<Key,U> r )
+ ptr_multimap_adapter& operator=( const ptr_multimap_adapter<Key,U>& r )
{
ptr_multimap_adapter clone( r );
this->swap( clone );
@@ -590,9 +592,10 @@
}
template< class U >
- void operator=( std::auto_ptr<U> r )
+ ptr_multimap_adapter& operator=( std::auto_ptr<U> r )
{
base_type::operator=( r );
+ return *this;
}
using base_type::release;
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 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -148,12 +148,12 @@
base_type )
template< class U >
- ptr_sequence_adapter( const ptr_sequence_adapter<U,VoidPtrSeq>& r )
+ explicit ptr_sequence_adapter( const ptr_sequence_adapter<U,VoidPtrSeq>& r )
: base_type( r )
{ }
template< class PtrContainer >
- ptr_sequence_adapter( std::auto_ptr<PtrContainer> clone )
+ explicit ptr_sequence_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
@@ -420,21 +420,28 @@
public: // C-array support
- void transfer( iterator before, T** from,
+ void transfer( iterator before, value_type* from,
size_type size, bool delete_from = true ) // strong
{
BOOST_ASSERT( from != 0 );
- this->base().insert( before.base(), from, from + size ); // strong
if( delete_from )
- 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
+ }
}
- T** c_array() // nothrow
+ value_type* c_array() // nothrow
{
if( this->empty() )
return 0;
T** res = reinterpret_cast<T**>( &this->begin().base()[0] );
- BOOST_ASSERT( &*this->begin().base() == (void**)res );
return res;
}
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 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -105,24 +105,24 @@
template< class Compare, class Allocator >
ptr_set_adapter_base( const Compare& comp,
- const Allocator& a )
+ const Allocator& a )
: base_type( comp, a )
{ }
template< class InputIterator, class Compare, class Allocator >
ptr_set_adapter_base( InputIterator first, InputIterator last,
- const Compare& comp,
- const Allocator& a )
+ const Compare& comp,
+ const Allocator& a )
: base_type( first, last, comp, a )
{ }
template< class U, class Set >
- ptr_set_adapter_base( const ptr_set_adapter_base<U,Set>& r )
+ explicit ptr_set_adapter_base( const ptr_set_adapter_base<U,Set>& r )
: base_type( r )
{ }
template< class PtrContainer >
- ptr_set_adapter_base( std::auto_ptr<PtrContainer> clone )
+ explicit ptr_set_adapter_base( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
@@ -264,8 +264,8 @@
public:
- explicit ptr_set_adapter( const key_compare& comp = key_compare(),
- const allocator_type& a = allocator_type() )
+ explicit ptr_set_adapter( const key_compare& comp = key_compare(),
+ const allocator_type& a = allocator_type() )
: base_type( comp, a )
{
BOOST_ASSERT( this->empty() );
@@ -282,12 +282,12 @@
}
template< class U, class Set >
- ptr_set_adapter( const ptr_set_adapter<U,Set>& r )
+ explicit ptr_set_adapter( const ptr_set_adapter<U,Set>& r )
: base_type( r )
{ }
template< class PtrContainer >
- ptr_set_adapter( std::auto_ptr<PtrContainer> clone )
+ explicit ptr_set_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
@@ -439,8 +439,8 @@
public:
- explicit ptr_multiset_adapter( const key_compare& comp = key_compare(),
- const allocator_type& a = allocator_type() )
+ ptr_multiset_adapter( const key_compare& comp = key_compare(),
+ const allocator_type& a = allocator_type() )
: base_type( comp, a )
{ }
@@ -454,12 +454,12 @@
}
template< class U, class Set >
- ptr_multiset_adapter( const ptr_multiset_adapter<U,Set>& r )
+ explicit ptr_multiset_adapter( const ptr_multiset_adapter<U,Set>& r )
: base_type( r )
{ }
template< class PtrContainer >
- ptr_multiset_adapter( std::auto_ptr<PtrContainer> clone )
+ explicit ptr_multiset_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
Modified: trunk/boost/ptr_container/ptr_vector.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_vector.hpp (original)
+++ trunk/boost/ptr_container/ptr_vector.hpp 2007-10-27 17:52:13 EDT (Sat, 27 Oct 2007)
@@ -46,8 +46,8 @@
base_class,
this_type );
- ptr_vector( size_type n,
- const allocator_type& alloc = allocator_type() )
+ explicit ptr_vector( size_type n,
+ const allocator_type& alloc = allocator_type() )
: base_class(alloc)
{
this->base().reserve( n );
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