
15 Oct
2004
15 Oct
'04
7:36 p.m.
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.