This has me very curious: Can you work up a quick hypothetical where this would be useful? I’m genuinely curious why you would want to do this rather than just not kill off an object until you are sure you don’t need it any longer.
Sure. I have a master class that hands off an object to a caller. When the caller is done with it, that object goes out of scope and, in the Destructor, calls MasterClass.Release( self ). Depending on conditions, the master class may decide to let it go or store it to hand off again later to another caller.
I could depend on the caller to call Release( object ) manually when it’s done with it, but this way makes it automagic and won’t fail even in the case of an exception.