Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-05-16 06:04:38


From: "hicks" <hicks_at_[hidden]>
> Hi Peter,
>
> you wrote
>
> /Consider this example:
> /weak_ptr<T> wp;
> /
> /// ...
> /
> /if(wp.get() != 0)
> /{
> / wp->f();
> / wp->g();
> /}

[...]

> The code can be simply fixed by writing
> if(wp.get() != 0)
> {
> wp->f();
> if (wp.get()) wp->g();
> else (...)
> }

I should also add that one of the weak_ptr iterations has an operator-> that
allowed the code above to work as expected (for some definition of
'exepcted.') Basically,

wp->f();

was syntactic sugar for

shared_ptr<T>(wp)->f();

and the invalidation of wp was signalled with an exception.

When we discussed this on the list, Darin suggested that this feature should
be removed since it isn't quite consistent with the usual definition of
operator-> for smart pointers; nobody objected.


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