|
Boost-Commit : |
From: nesotto_at_[hidden]
Date: 2007-10-22 16:26:52
Author: nesotto
Date: 2007-10-22 16:26:51 EDT (Mon, 22 Oct 2007)
New Revision: 40302
URL: http://svn.boost.org/trac/boost/changeset/40302
Log:
added copyability to all containers
Text files modified:
trunk/boost/ptr_container/detail/reversible_ptr_container.hpp | 62 +++++++++++++++++++++++----------------
trunk/boost/ptr_container/ptr_vector.hpp | 3 +
2 files changed, 39 insertions(+), 26 deletions(-)
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-22 16:26:51 EDT (Mon, 22 Oct 2007)
@@ -142,6 +142,12 @@
Cont& c_private() { return c_; }
const Cont& c_private() const { return c_; }
+ protected: // todo: use base() instead of c_private().
+ Cont& base() { return c_; }
+
+ public:
+ const Cont& base() const { return c_; }
+
public: // typedefs
typedef Ty_* value_type;
typedef Ty_* pointer;
@@ -276,25 +282,8 @@
ForwardIterator iter = begin;
std::advance( iter, n );
return iter;
- }
-
- private:
- reversible_ptr_container( const reversible_ptr_container& );
- void operator=( const reversible_ptr_container& );
-
- public: // foundation! should be protected!
- explicit reversible_ptr_container( const allocator_type& a = allocator_type() )
- : c_( a )
- {}
-
- template< class PtrContainer >
- explicit reversible_ptr_container( std::auto_ptr<PtrContainer> clone )
- : c_( allocator_type() )
- {
- swap( *clone );
- }
+ }
- private:
template< class I >
void constructor_impl( I first, I last, std::input_iterator_tag ) // basic
{
@@ -313,8 +302,37 @@
clone_back_insert( first, last );
}
+ public: // foundation! should be protected!
+ explicit reversible_ptr_container( const allocator_type& a = allocator_type() )
+ : c_( a )
+ {}
+
+ template< class PtrContainer >
+ explicit reversible_ptr_container( std::auto_ptr<PtrContainer> clone )
+ : c_( allocator_type() )
+ {
+ swap( *clone );
+ }
+
+ explicit reversible_ptr_container( const reversible_ptr_container& 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=( const reversible_ptr_container& r ) // strong
+ {
+ reversible_ptr_container clone( r );
+ swap( clone );
+ return *this;
+ }
- public:
// overhead: null-initilization of container pointer (very cheap compared to cloning)
// overhead: 1 heap allocation (very cheap compared to cloning)
template< class InputIterator >
@@ -350,12 +368,6 @@
remove_all();
}
- template< class PtrContainer >
- void operator=( std::auto_ptr<PtrContainer> clone )
- {
- swap( *clone );
- }
-
public:
allocator_type get_allocator() const
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-22 16:26:51 EDT (Mon, 22 Oct 2007)
@@ -50,7 +50,8 @@
const allocator_type& alloc = allocator_type() )
: base_class(alloc)
{
- this->c_private().reserve( n );
+ if( n > 0 )
+ this->c_private().reserve( n );
}
public: // serialization
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