Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-10-13 11:33:20

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;

I'm saying this, because I just made this mistake a few hours ago...
After a while, the shared_ptr<> constructor started to throw at me ;)


John Torjo,    Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- v1.5 - tooltips at your fingertips (work for menus too!)
    + bitmap buttons (work for MessageBox too!)
    + tab dialogs, hyper links, lite html

Boost list run by bdawes at, gregod at, cpdaniel at, john at