
18 Jan
2008
18 Jan
'08
7:58 p.m.
Tobias Schwinger:
Peter Dimov wrote:
What is the reason to prefer the current instance/lease formulation instead of
typedef ... instance_type; instance_type instance(); // automatically serves as a lease
?
As we can't expose the instance when automatic locking is done, it is supposed to provide a means to not have to access the instance directly.
I'm not sure what this reformulation cannot do that the original can. An ordinary singleton can define instance_type as T*. A synchronized singleton can define instance_type as the moral equivalent of shared_ptr<T> (with a hidden unlocking deleter). What am I missing?