
20 Oct
2004
20 Oct
'04
9:18 p.m.
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. -- Colin