On 04/07/11 16:59, Dmitry Yemanov wrote:
> 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.

Certainly. The only thing to decide is how to make people type

att.detach();

instead of

att->detach();

Possible way is not to have overloaded -> at all, i.e. not expose
pointer to the outer world. Instead all required methods should be
present in smart class itself.


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to