Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52924 - in sandbox/boost0x: boost/smart_ptr libs/smart_ptr/test
From: whatwasthataddress_at_[hidden]
Date: 2009-05-11 16:26:03


Author: tzlaine
Date: 2009-05-11 16:26:03 EDT (Mon, 11 May 2009)
New Revision: 52924
URL: http://svn.boost.org/trac/boost/changeset/52924

Log:
- Replaced static_cast< * && >(x) with std::move(x) for uniformity (previously,
a mix of the two conventions was used).
- Fixed misnamed test file names inside intrusive_ptr_move_test.cpp and
weak_ptr_move_test.cpp.
- Changed the weak_ptr move operations back to assigning the moved-from
weak_ptr's px member to 0. This will hopefully make things clearer when
debugging.
- Uncommented #include <boost/config.hpp> at the top of
intrusive_ptr_move_test.cpp, so that BOOST_MSVC is properly defined when needed
elsewhere in the file.

Text files modified:
   sandbox/boost0x/boost/smart_ptr/shared_ptr.hpp | 4 ++--
   sandbox/boost0x/boost/smart_ptr/weak_ptr.hpp | 12 ++++++------
   sandbox/boost0x/libs/smart_ptr/test/intrusive_ptr_move_test.cpp | 10 +++++-----
   sandbox/boost0x/libs/smart_ptr/test/shared_ptr_move_test.cpp | 12 ++++++------
   sandbox/boost0x/libs/smart_ptr/test/weak_ptr_move_test.cpp | 12 ++++++------
   5 files changed, 25 insertions(+), 25 deletions(-)

Modified: sandbox/boost0x/boost/smart_ptr/shared_ptr.hpp
==============================================================================
--- sandbox/boost0x/boost/smart_ptr/shared_ptr.hpp (original)
+++ sandbox/boost0x/boost/smart_ptr/shared_ptr.hpp 2009-05-11 16:26:03 EDT (Mon, 11 May 2009)
@@ -368,14 +368,14 @@
 
     shared_ptr & operator=( shared_ptr && r ) // never throws
     {
- this_type( static_cast< shared_ptr && >( r ) ).swap( *this );
+ this_type( std::move( r ) ).swap( *this );
         return *this;
     }
 
     template<class Y>
     shared_ptr & operator=( shared_ptr<Y> && r ) // never throws
     {
- this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this );
+ this_type( std::move( r ) ).swap( *this );
         return *this;
     }
 

Modified: sandbox/boost0x/boost/smart_ptr/weak_ptr.hpp
==============================================================================
--- sandbox/boost0x/boost/smart_ptr/weak_ptr.hpp (original)
+++ sandbox/boost0x/boost/smart_ptr/weak_ptr.hpp 2009-05-11 16:26:03 EDT (Mon, 11 May 2009)
@@ -88,19 +88,19 @@
 #endif
     : px(r.lock().get()), pn(std::move(r.pn)) // never throws
     {
- //not necesary to set r.px = 0 as r.pn.pi_ == 0
+ r.px = 0;
     }
 
- // for better efficiency in the T == Y case
+ // for better efficiency in the T == Y case
     weak_ptr( weak_ptr && r ): px( r.px ), pn(std::move(r.pn)) // never throws
     {
- //not necesary to set r.px = 0 as r.pn.pi_ == 0
+ r.px = 0;
     }
 
- // for better efficiency in the T == Y case
+ // for better efficiency in the T == Y case
     weak_ptr & operator=( weak_ptr && r ) // never throws
     {
- this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
+ this_type( std::move( r ) ).swap( *this );
         return *this;
     }
 
@@ -136,7 +136,7 @@
     template<class Y>
     weak_ptr & operator=(weak_ptr<Y> && r)
     {
- this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this );
+ this_type( std::move( r ) ).swap( *this );
         return *this;
     }
 

Modified: sandbox/boost0x/libs/smart_ptr/test/intrusive_ptr_move_test.cpp
==============================================================================
--- sandbox/boost0x/libs/smart_ptr/test/intrusive_ptr_move_test.cpp (original)
+++ sandbox/boost0x/libs/smart_ptr/test/intrusive_ptr_move_test.cpp 2009-05-11 16:26:03 EDT (Mon, 11 May 2009)
@@ -1,4 +1,4 @@
-//#include <boost/config.hpp>
+#include <boost/config.hpp>
 
 #if defined(BOOST_MSVC)
 
@@ -17,7 +17,7 @@
 #endif
 
 //
-// intrusive_ptr_test.cpp
+// intrusive_ptr_move_test.cpp
 //
 // Copyright (c) 2002-2005 Peter Dimov
 //
@@ -136,7 +136,7 @@
         boost::intrusive_ptr<X> p( new X );
         BOOST_TEST( N::base::instances == 1 );
 
- boost::intrusive_ptr<X> p2( static_cast< boost::intrusive_ptr<X> && >( p ) );
+ boost::intrusive_ptr<X> p2( std::move( p ) );
         BOOST_TEST( N::base::instances == 1 );
         BOOST_TEST( p.get() == 0 );
 
@@ -149,7 +149,7 @@
         BOOST_TEST( N::base::instances == 1 );
 
         boost::intrusive_ptr<X> p2;
- p2 = static_cast< boost::intrusive_ptr<X> && >( p );
+ p2 = std::move( p );
         BOOST_TEST( N::base::instances == 1 );
         BOOST_TEST( p.get() == 0 );
 
@@ -163,7 +163,7 @@
 
         boost::intrusive_ptr<X> p2( new X );
         BOOST_TEST( N::base::instances == 2 );
- p2 = static_cast< boost::intrusive_ptr<X> && >( p );
+ p2 = std::move( p );
         BOOST_TEST( N::base::instances == 1 );
         BOOST_TEST( p.get() == 0 );
 

Modified: sandbox/boost0x/libs/smart_ptr/test/shared_ptr_move_test.cpp
==============================================================================
--- sandbox/boost0x/libs/smart_ptr/test/shared_ptr_move_test.cpp (original)
+++ sandbox/boost0x/libs/smart_ptr/test/shared_ptr_move_test.cpp 2009-05-11 16:26:03 EDT (Mon, 11 May 2009)
@@ -43,11 +43,11 @@
         boost::shared_ptr<X> p( new X );
         BOOST_TEST( X::instances == 1 );
 
- boost::shared_ptr<X> p2( static_cast< boost::shared_ptr<X> && >( p ) );
+ boost::shared_ptr<X> p2( std::move( p ) );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p.get() == 0 );
 
- boost::shared_ptr<void> p3( static_cast< boost::shared_ptr<X> && >( p2 ) );
+ boost::shared_ptr<void> p3( std::move( p2 ) );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p2.get() == 0 );
 
@@ -60,12 +60,12 @@
         BOOST_TEST( X::instances == 1 );
 
         boost::shared_ptr<X> p2;
- p2 = static_cast< boost::shared_ptr<X> && >( p );
+ p2 = std::move( p );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p.get() == 0 );
 
         boost::shared_ptr<void> p3;
- p3 = static_cast< boost::shared_ptr<X> && >( p2 );
+ p3 = std::move( p2 );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p2.get() == 0 );
 
@@ -79,13 +79,13 @@
 
         boost::shared_ptr<X> p2( new X );
         BOOST_TEST( X::instances == 2 );
- p2 = static_cast< boost::shared_ptr<X> && >( p );
+ p2 = std::move( p );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p.get() == 0 );
 
         boost::shared_ptr<void> p3( new X );
         BOOST_TEST( X::instances == 2 );
- p3 = static_cast< boost::shared_ptr<X> && >( p2 );
+ p3 = std::move( p2 );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p2.get() == 0 );
 

Modified: sandbox/boost0x/libs/smart_ptr/test/weak_ptr_move_test.cpp
==============================================================================
--- sandbox/boost0x/libs/smart_ptr/test/weak_ptr_move_test.cpp (original)
+++ sandbox/boost0x/libs/smart_ptr/test/weak_ptr_move_test.cpp 2009-05-11 16:26:03 EDT (Mon, 11 May 2009)
@@ -1,5 +1,5 @@
 //
-// shared_ptr_move_test.cpp
+// weak_ptr_move_test.cpp
 //
 // Copyright (c) 2007 Peter Dimov
 //
@@ -45,12 +45,12 @@
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p.use_count() == 1 );
 
- boost::weak_ptr<X> p2( static_cast< boost::weak_ptr<X> && >( p ) );
+ boost::weak_ptr<X> p2( std::move( p ) );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p2.use_count() == 1 );
         BOOST_TEST( p.expired() );
 
- boost::weak_ptr<void> p3( static_cast< boost::weak_ptr<X> && >( p2 ) );
+ boost::weak_ptr<void> p3( std::move( p2 ) );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p3.use_count() == 1 );
         BOOST_TEST( p2.expired() );
@@ -73,7 +73,7 @@
         BOOST_TEST( p.expired() );
 
         boost::weak_ptr<void> p3;
- p3 = static_cast< boost::weak_ptr<X> && >( p2 );
+ p3 = std::move( p2 );
         BOOST_TEST( X::instances == 1 );
         BOOST_TEST( p3.use_count() == 1 );
         BOOST_TEST( p2.expired() );
@@ -92,7 +92,7 @@
         boost::shared_ptr<X> p_2( new X );
         boost::weak_ptr<X> p2( p_2 );
         BOOST_TEST( X::instances == 2 );
- p2 = static_cast< boost::weak_ptr<X> && >( p );
+ p2 = std::move( p );
         BOOST_TEST( X::instances == 2 );
         BOOST_TEST( p2.use_count() == 1 );
         BOOST_TEST( p.expired() );
@@ -101,7 +101,7 @@
         boost::shared_ptr<void> p_3( new X );
         boost::weak_ptr<void> p3( p_3 );
         BOOST_TEST( X::instances == 3 );
- p3 = static_cast< boost::weak_ptr<X> && >( p2 );
+ p3 = std::move( p2 );
         BOOST_TEST( X::instances == 3 );
         BOOST_TEST( p3.use_count() == 1 );
         BOOST_TEST( p2.expired() );


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