Boost logo

Boost :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2006-03-29 09:53:43


Paul Mensonides wrote:
>>-----Original Message-----
>>From: boost-bounces_at_[hidden]
>>[mailto:boost-bounces_at_[hidden]] On Behalf Of Larry Evans
>
>
>>Or maybe I'm misunderstanding your definition of "safe"?
>
>
> One way that it is safer is in sequence points, e.g.
>
> f( shared_ptr<X>(new X(1, 2, 3)), shared_ptr<Y>(new Y(1, 2, 3)) );
>
> f( make_shared_ptr<X>(1, 2, 3), make_shared_ptr<Y>(1, 2, 3) );
>
> The latter is safe, whereas the former is not.

Another great example of exception-unsafe code is

std::map<std::string,boost::shared_ptr<T>> m;
m["foo"] = boost::shared_ptr<T>( new T );

-Thorsten


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