
4 Sep
2005
4 Sep
'05
11:03 p.m.
Alexander Terekhov <terekhov@web.de> writes:
Peter Dimov wrote: [...]
Things like auto_ptr aside, you'd need to templatize the once_flag on the return type then, since the first time value needs to be stored somewhere. Is this worth the hassle?
I think yes.
How about the attached version? The result is stored on the heap, which adds some performance cost, but the once_flag itself doesn't need templating. I haven't yet adjusted it to avoid this heap allocation for void functions. It does mean that the initializer is now an aggregate initializer rather than a constant, as for my original Semaphore-based version. Anthony -- Anthony Williams Software Developer