From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2005-09-04 18:03:29
Alexander Terekhov <terekhov_at_[hidden]> 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 Williams Software Developer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk