Boost logo

Boost :

From: colin.rafferty_at_[hidden]
Date: 2004-10-20 16:18:38

Peter Dimov wrote:
> Colin Rafferty wrote:

>> Shouldn't the constructor in intrusive_ptr be explicit?

> No, the constructor is implicit by design. Do you have a case where the
> implicit constructor causes problems?

Sure, this is the same problem as for shared_ptr<>.

    extern void foo(const intrusive_ptr<Bar>&);

    void baz()
        Bar* bar = new Bar;
        foo(bar); // oops!
        delete bar;

I thought I was passing a raw pointer into foo(), but I'm actually
creating a temporary intrusive_ptr<Bar>, passing that in, and then
destroying the temporary and the pointer.


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