
Alexander Terekhov <terekhov@web.de> writes:
Anthony Williams wrote:
However, our once_flag can store a result of a user-defined type, which may therefore require proper destruction, so that it can notify other processes, send network packets, write to a file, or whatever; this therefore needs dealing with somehow before process termination.
User would then call _destroy() or _reset() (the later is likely to be called multiple times). I won't tell you "how". Trade secret.
Don't be such a tease! class X { public X() { acquire_resource(); } void do_something(); ~X() { release_resource(); } }; X get_X(); void f() { static once_flag once; call_once(get_X,once).do_something(); // how do we clean up the X associated with "once", and release it's // resource? // We can't sensibly call once_destroy() here. } Anthony -- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk