|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52774 - in sandbox/boost0x/boost/smart_ptr: . detail
From: tobi_at_[hidden]
Date: 2009-05-05 16:59:26
Author: tobias.loew
Date: 2009-05-05 16:59:25 EDT (Tue, 05 May 2009)
New Revision: 52774
URL: http://svn.boost.org/trac/boost/changeset/52774
Log:
extended weak_ptr and intrusive_ptr with move constructors and assignments.
Move-semantics for weak_ptrs works only if both weak_ptr are of the same template-type T
Text files modified:
sandbox/boost0x/boost/smart_ptr/detail/shared_count.hpp | 14 ++++++++++++++
sandbox/boost0x/boost/smart_ptr/intrusive_ptr.hpp | 17 +++++++++++++++++
sandbox/boost0x/boost/smart_ptr/weak_ptr.hpp | 21 +++++++++++++++++++++
3 files changed, 52 insertions(+), 0 deletions(-)
Modified: sandbox/boost0x/boost/smart_ptr/detail/shared_count.hpp
==============================================================================
--- sandbox/boost0x/boost/smart_ptr/detail/shared_count.hpp (original)
+++ sandbox/boost0x/boost/smart_ptr/detail/shared_count.hpp 2009-05-05 16:59:25 EDT (Tue, 05 May 2009)
@@ -333,6 +333,20 @@
if(pi_ != 0) pi_->weak_add_ref();
}
+// Move support
+
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+ weak_count(weak_count && r): pi_(r.pi_) // nothrow
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+ , id_(weak_count_id)
+#endif
+ {
+ r.pi_ = 0;
+ }
+
+#endif
+
~weak_count() // nothrow
{
if(pi_ != 0) pi_->weak_release();
Modified: sandbox/boost0x/boost/smart_ptr/intrusive_ptr.hpp
==============================================================================
--- sandbox/boost0x/boost/smart_ptr/intrusive_ptr.hpp (original)
+++ sandbox/boost0x/boost/smart_ptr/intrusive_ptr.hpp 2009-05-05 16:59:25 EDT (Tue, 05 May 2009)
@@ -111,6 +111,23 @@
#endif
+// Move support
+
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+ intrusive_ptr(intrusive_ptr && rhs): px( rhs.px )
+ {
+ rhs.px = 0;
+ }
+
+ intrusive_ptr & operator=(intrusive_ptr && rhs)
+ {
+ this_type(std::move(rhs)).swap(*this);
+ return *this;
+ }
+
+#endif
+
intrusive_ptr & operator=(intrusive_ptr const & rhs)
{
this_type(rhs).swap(*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-05 16:59:25 EDT (Tue, 05 May 2009)
@@ -109,6 +109,27 @@
#endif
+
+// Move support
+
+#if defined( BOOST_HAS_RVALUE_REFS )
+
+ weak_ptr( weak_ptr && r ): px( r.px ), pn() // never throws
+ {
+ pn.swap( r.pn );
+ r.px = 0;
+ }
+
+ weak_ptr & operator=( weak_ptr && r ) // never throws
+ {
+ this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
+ return *this;
+ }
+
+#endif
+
+
+
shared_ptr<T> lock() const // never throws
{
return shared_ptr<element_type>( *this, boost::detail::sp_nothrow_tag() );
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