On Fri, 29 Jan 2010 11:02:39 -0800, Barry Kelly <✉nospam.codegear.com> wrote:
>It is equivalent to the try / finally etc. owing to the mechanism behind >reference counting.
thank you, that was the closest approach to what I was looking for. that's fine for specific types of guards and I definitely will use that interface-based way. moreover I just discovered that I already used the very same approach back in 2008 when I implemented delphi-based component TVPool for general purpose pooling. there are two functions for getting pooled instance: GetObjInstance and GetIntfInstance. second one returning interface. quite strange I didn't propogated it broadly
now what about general purpose scoped guard which is created and used via ON_BLOCK_EXIT(SomeFunc,Type1 var1,Type2 var2,Type3 var3) and ON_BLOCK_EXIT_OBJ(SomeObject,TSomeObject::MemberFunc,Type1 param1,Type2 param2,Type3 param3)
is it possible to implement those using say generics or something?
thanks again for your explanation
-- Vladimir Ulchenko aka vavan