Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr singleton
From: Alessandro Re (akirosspower_at_[hidden])
Date: 2008-10-16 18:53:02

On Fri, Oct 17, 2008 at 12:42 AM, Peter Dimov <pdimov_at_[hidden]> wrote:
> The problem is that the default constructor may be invoked after the first
> call to Register::global, overwriting _global and resetting it to empty. The
> first subsequent call to global() would now reinitialize it.
> You can avoid this by making _global a local static:
> static RegisterP global()
> {
> static RegisterP _global( new Register );
> return _global;
> }

Yes! You're right :)
I just tried with a debugger and is as you say.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at