Boost logo

Boost :

From: Jason Hise (0xchaos_at_[hidden])
Date: 2006-12-11 11:12:17

On 12/11/06, Johan Råde <rade_at_[hidden]> wrote:
> I have singleton class X.
> The instance of X is constructed the first time it is used,
> and is destroyed during the static destruction phase at app termination.
> X::X() reads data from a ptree
> X::~X() writes data to a ptree
> My app crashes in X::~X().
> The reason is that ptree uses static variables.

Static variables are destroyed in reverse order of the completion of
their constructors. Therefore, if you make sure to call any ptree
functions used by ~X() in X(), this will make sure that the static
variables needed by ~X() are created before construction of X is
complete. That gives you the guarantee that X will be destroyed
before any of the static vars it depends on.


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