
Alexander Terekhov <terekhov@web.de> writes:
Anthony Williams wrote: [...]
Destruction of once_flags with static storage duration.
If we store the return value along with the once_flag, then we really ought to destroy it properly, when the once_flag is destroyed. If a once_flag has static storage duration, and has a non-trivial destructor that does cleanup, then we have a classic singleton cleanup problem, as John Maddock pointed out --- the order of static destruction can now be important.
You mean an extra non-POD version? That's not your problem... as long as you provide a POD version + call_once_reset/destroy().
So, you're suggesting that we store the result with the once_flag, and then leave it up to users to schedule a call to call_once_reset, to ensure the result gets cleared up? Hmm. I'd still like to know how the user can safely schedule the call to call_once_reset, so it doesn't cause problems. I suppose there's an element to which it doesn't really matter; the result will just be reinitialized if there's a subsequent call_once. I don't like leaving things as "not my problem", unless I can see that there is a safe solution. Anthony -- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk