Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-07 05:44:02


From: "Andrew J Bromage" <ajb_at_[hidden]>
> G'day all.
>
> In retrospect I shouldn't have brought up a "more powerful"
> call_once function, because that's not what I want at all. What
> I "really" want is this:
>
> class once
> {
> public:
> once();
> ~once();
> call_once(function0<void>&);
> };

Are you sure that you want that. The whole point of the

template<class F> void call_once(F f, once_flag & flag);

construct is that once_flag is a POD, and can be statically initialized, so
you don't have to worry about initialization order issues.

Your "once" object is dynamically initialized. It is pretty much the same as
a boost::mutex; there is no reason for it to be more efficient than a mutex.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk