Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73202 - trunk/boost/smart_ptr
From: pdimov_at_[hidden]
Date: 2011-07-17 16:35:44


Author: pdimov
Date: 2011-07-17 16:35:44 EDT (Sun, 17 Jul 2011)
New Revision: 73202
URL: http://svn.boost.org/trac/boost/changeset/73202

Log:
Add copy constructor/assignment - in C++0x, move disables implicit copy.
Text files modified:
   trunk/boost/smart_ptr/shared_array.hpp | 20 +++++++++++++++++++-
   trunk/boost/smart_ptr/shared_ptr.hpp | 12 +++++++++++-
   trunk/boost/smart_ptr/weak_ptr.hpp | 18 +++++++++++++++++-
   3 files changed, 47 insertions(+), 3 deletions(-)

Modified: trunk/boost/smart_ptr/shared_array.hpp
==============================================================================
--- trunk/boost/smart_ptr/shared_array.hpp (original)
+++ trunk/boost/smart_ptr/shared_array.hpp 2011-07-17 16:35:44 EDT (Sun, 17 Jul 2011)
@@ -69,7 +69,25 @@
     {
     }
 
-// generated copy constructor, assignment, destructor are fine
+// generated copy constructor, destructor are fine...
+
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+// ... except in C++0x, move disables the implicit copy
+
+ shared_array( shared_array const & r ): px( r.px ), pn( r.pn ) // never throws
+ {
+ }
+
+#endif
+
+ // assignment
+
+ shared_array & operator=( shared_array const & r ) // never throws
+ {
+ this_type( r ).swap( *this );
+ return *this;
+ }
 
     void reset(T * p = 0)
     {

Modified: trunk/boost/smart_ptr/shared_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/shared_ptr.hpp (original)
+++ trunk/boost/smart_ptr/shared_ptr.hpp 2011-07-17 16:35:44 EDT (Sun, 17 Jul 2011)
@@ -197,7 +197,17 @@
         boost::detail::sp_enable_shared_from_this( this, p, p );
     }
 
-// generated copy constructor, destructor are fine
+// generated copy constructor, destructor are fine...
+
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+// ... except in C++0x, move disables the implicit copy
+
+ shared_ptr( shared_ptr const & r ): px( r.px ), pn( r.pn ) // never throws
+ {
+ }
+
+#endif
 
     template<class Y>
     explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw

Modified: trunk/boost/smart_ptr/weak_ptr.hpp
==============================================================================
--- trunk/boost/smart_ptr/weak_ptr.hpp (original)
+++ trunk/boost/smart_ptr/weak_ptr.hpp 2011-07-17 16:35:44 EDT (Sun, 17 Jul 2011)
@@ -40,8 +40,24 @@
     {
     }
 
-// generated copy constructor, assignment, destructor are fine
+// generated copy constructor, assignment, destructor are fine...
 
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+// ... except in C++0x, move disables the implicit copy
+
+ weak_ptr( weak_ptr const & r ): px( r.px ), pn( r.pn ) // never throws
+ {
+ }
+
+ weak_ptr & operator=( weak_ptr const & r ) // never throws
+ {
+ px = r.px;
+ pn = r.pn;
+ return *this;
+ }
+
+#endif
 
 //
 // The "obvious" converting constructor implementation:


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