From: Dmitry Y. <fir...@ya...> - 2011-04-07 12:59:34
|
07.04.2011 16:47, Alex Peshkoff wrote: > But with smart pointers we must do the following: > > Smart<IAttachment> at = ... > att->release(); // refCounter == 1 > att->blaBlaBla(); > > We want to detach - and here problems come. We can't simply call: > > att->detach(); > > because ~Smart() will try to release an already destroyed object, > causing AV. True for dumb universal smart pointers. But a smarter one could overload not only operator-> but also the detach() method and mark itself as not requiring release inside the dtor. Dmitry |