Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55147 - sandbox/fmhess/boost/smart_ptr
From: fmhess_at_[hidden]
Date: 2009-07-24 16:43:15


Author: fmhess
Date: 2009-07-24 16:43:14 EDT (Fri, 24 Jul 2009)
New Revision: 55147
URL: http://svn.boost.org/trac/boost/changeset/55147

Log:
Added rvalue reference support to shared_ptr/weak_ptr implementations.

Text files modified:
   sandbox/fmhess/boost/smart_ptr/shared_ptr.hpp | 24 ++++++++++++++++++++++--
   sandbox/fmhess/boost/smart_ptr/weak_ptr.hpp | 17 ++++++++++++++++-
   2 files changed, 38 insertions(+), 3 deletions(-)

Modified: sandbox/fmhess/boost/smart_ptr/shared_ptr.hpp
==============================================================================
--- sandbox/fmhess/boost/smart_ptr/shared_ptr.hpp (original)
+++ sandbox/fmhess/boost/smart_ptr/shared_ptr.hpp 2009-07-24 16:43:14 EDT (Fri, 24 Jul 2009)
@@ -69,7 +69,7 @@
                 {}
     template<class Y>
 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
- shared_ptr( shared_ptr<Y> const & r, typename generic_ptr::detail::sp_enable_if_convertible<Y*,T*>::type = detail::sp_empty() )
+ shared_ptr( shared_ptr<Y> const & r, typename detail::sp_enable_if_convertible<Y,T>::type = detail::sp_empty() )
 #else
                 shared_ptr( shared_ptr<Y> const & r )
 #endif
@@ -90,7 +90,27 @@
                 template<class Y>
                 explicit shared_ptr(weak_ptr<Y> const & r): base_type(static_cast<generic_ptr::weak<Y*> const &>(r))
                 {}
-
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ shared_ptr( shared_ptr && r ): base_type(std::move<base_type>(r))
+ {}
+ template<class Y>
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+ shared_ptr( shared_ptr<Y> && r, typename detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
+#else
+ shared_ptr( shared_ptr<Y> && r )
+#endif
+ : base_type(std::move<generic_ptr::shared<Y*> >(r))
+ {}
+ shared_ptr & operator=( shared_ptr && r )
+ {
+ return static_cast<shared_ptr&>(base_type::operator=(std::move<base_type>(r)));
+ }
+ template<class Y>
+ shared_ptr & operator=( shared_ptr<Y> && r )
+ {
+ return static_cast<shared_ptr&>(base_type::operator=(std::move<generic_ptr::shared<Y*> >(r)));
+ }
+#endif // BOOST_NO_RVALUE_REFERENCES
                 template<typename Y>
                 shared_ptr & operator=( std::auto_ptr<Y> & r )
                 {

Modified: sandbox/fmhess/boost/smart_ptr/weak_ptr.hpp
==============================================================================
--- sandbox/fmhess/boost/smart_ptr/weak_ptr.hpp (original)
+++ sandbox/fmhess/boost/smart_ptr/weak_ptr.hpp 2009-07-24 16:43:14 EDT (Fri, 24 Jul 2009)
@@ -37,8 +37,23 @@
 #else
                 weak_ptr( shared_ptr<Y> const & r )
 #endif
- :base_type(static_cast<generic_ptr::shared<Y*> const &>(r))
+ : base_type(static_cast<generic_ptr::shared<Y*> const &>(r))
                 {}
+#ifndef BOOST_NO_RVALUE_REFERENCES
+ template<class Y>
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+ weak_ptr( weak_ptr<Y> && r, typename detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
+#else
+ weak_ptr( weak_ptr<Y> && r )
+#endif
+ : base_type(std::move<generic_ptr::weak<Y*> >(r))
+ {}
+ template<class Y>
+ weak_ptr & operator=(weak_ptr<Y> && r)
+ {
+ return static_cast<weak_ptr&>(base_type::operator=(std::move<generic_ptr::weak<Y*> >(r)));
+ }
+#endif
                 shared_ptr<T> lock() const
                 {
                         return base_type::lock();


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