Boost logo

Boost :

Subject: Re: [boost] Is there any interest in static constructors?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2013-01-31 21:31:19

On 31/01/13 21:59, Alexander Stoyan wrote:
> Hello community,
> I have implemented static constructors for my personal needs. They
> guarantee construction of static data prior main execution, and allow
> control the order of static initialization. The code now implemented and
> tested for VS2012 and GCC.
> I couldn't find anything like this in the boost library but consider it to
> be useful for C++ developers.
> More detailed approach on my blog page:
> Feedbacks are very appreciated.

I'm not sure I see the point. This uses static at the member function scope.
The object will only be constructed when instance() is called. If the
constructor of the object depends on other singletons, then instance()
of those other singletons will naturally be called before, and therefore
they will end up being constructed before.
Sure, this doesn't protect against recursion, but recursion in object
construction looks like a logical error anyway.

Before I clicked your link I thought you were providing a solution for
ordering static constructors for class-scope static members or global

Boost list run by bdawes at, gregod at, cpdaniel at, john at