Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-10-16 08:47:54


Peter Dimov wrote:

> 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.

True, sorry, I meant this:

shared_ptr<T> val(weak);

The point still remains.

Best,
John

-- 
John Torjo,    Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/
-- 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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk