
21 Feb
2009
21 Feb
'09
2:54 a.m.
On Feb 20, 2009, at 1:27 PM, Yang Zhang wrote:
From http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/scoped_ptr.htm :
"If scoped_ptr had a release() member, it would become possible to transfer ownership of the held pointer, weakening its role as a way of limiting resource lifetime to a given context. Use std::auto_ptr where transfer of ownership is required. (supplied by Dave Abrahams)"
But there already is a way to escape the scope, via swap().
Would it make more sense to just provide release() and have users specify const if they want? (const scoped_ptr/scoped_array would effectively disallow swapping/releasing.)
<opinion> http://home.roadrunner.com/~hinnant/unique_ptr03.html (search for "scoped_ptr") </opinion> -Howard