Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-10-15 14:36:43


John Torjo wrote:
> Hi Peter,
>
> Just a thought: perhaps this constructor:
> explicit shared_ptr(weak_ptr<Y> const & r);
>
> should be private,
> and the only way to create a shared_ptr from a weak_ptr is:
>
> shared_ptr<T> val = weak->lock();
>
> This way, the shared_ptr public constructors will never throw. Users
> will not make mistakes like this:
>
> shared_ptr<T> val = weak;

This shouldn't compile on a reasonably compliant compiler, because the
constructor is explicit.


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