Boost logo

Boost :

From: Pierre THIERRY (nowhere.man_at_[hidden])
Date: 2006-01-31 06:25:16


It seems to me that smart pointers could have the same semantics that
plain pointers have (it's also the orientation taken by other smart
pointers, like those in Glibmm). Here is my proposed patch against CVS
HEAD:

Index: boost/scoped_ptr.hpp
===================================================================
--- boost/scoped_ptr.hpp.orig
+++ boost/scoped_ptr.hpp
@@ -101,6 +101,12 @@
         return *this;
     }

+ scoped_ptr & operator=(T * rhs)
+ {
+ this_type(rhs).swap(*this);
+ return *this;
+ }
+
     T * get() const // never throws
     {
         return ptr;
Index: boost/shared_ptr.hpp
===================================================================
--- boost/shared_ptr.hpp.orig
+++ boost/shared_ptr.hpp
@@ -246,6 +246,12 @@

 #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION

+ shared_ptr & operator=(T * r)
+ {
+ this_type(r).swap(*this);
+ return *this;
+ }
+
 #endif // BOOST_NO_AUTO_PTR

 #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)

Regards,
Nowhere man

-- 
nowhere.man_at_[hidden]
OpenPGP 0xD9D50D8A

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk