Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-07-14 14:07:45


At 06:17 PM 7/14/99 +0100, Jon Jagger wrote:

>
>Hi everyone,

Hi Jon:-)

>I think the question really boils down to whether we want to support
this
>as an idiom...
>
> shared_ptr<widget> sp(new widget(...));
>
>The problem is that given...
>
> template<typename T>
> class shared_ptr
> {
> public:
> explicit shared_ptr(T * p = 0) : px(p), pn(new long(1)) {}
> ...
> private:
> T * px;
> mutable long * pn;
> };

You lost me. The current version of smart_ptr.h defines the ctor as:

  explicit shared_ptr(T* p =0) : px(p) {
     try { pn = new long(1); } // fix: prevent leak if new throws
     catch (...) { delete p; throw; }
     }

Dave Abrahams supplied the fix, which was applied April 27th.

(That is not to say your other points aren't worthwhile, but I don't
want people to think there is a problem with the current version of
smart_ptr.h.)

--Beman

------------------------------------------------------------------------

eGroups.com home: http://www.egroups.com/group/boost
http://www.egroups.com - Simplifying group communications


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