Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr as reference argument
From: Igor R (boost.lists_at_[hidden])
Date: 2009-03-19 12:34:14

> //possible misuse
> void foo()
> {
>      Bar bar;
>      shared_ptr<int> ptr = shared_ptr<int>(new int(10));
>      bar.set(ptr);
> } //  BOOM!!! => ptr is destroyed before the Bar::~Bar() is called
> If you do not program real time soft, it is probably always better to copy
> sp.

In your example, how would the behavior change, if Bar::set would take
the pram by value?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at