
18 Jul
2005
18 Jul
'05
10:09 a.m.
Jason Hise writes:
I am adding a policy to control exactly what happens if creation is attempted while the singleton instance exists. The options thus far include throwing an exception, doing nothing, or destroying and recreating the singleton, depending on the policy used.
Could you post some source code that illustrates what you mean by "creating" an instance? The usual approach to initializing static instances is call_once() from Boost.Thread; so I am curious to know how your approach compares to that.
Does it make sense to have a similar policy for what happens when attempting to destroy an already destroyed instance?
A failed assertion would be my preferred way to handle this condition; I don't see the need for a policy class. Peter