suppose I have a .cpp file:
static Foo aFoo;
Foo& staticFoo(){
return aFoo;
}
Foo& singletonFoo(){ // not thread safe in c++-03
static Foo staticFoo;
return staticFoo;
}
and a .h file that exposes these functions (but not aFoo directly).
- Am I certain that
aFoois initialized prior tostaticFoo? - Am I certain that
staticFoois destroyed afteraFoo? - Am I certain that
aFoois destroyed after any automatic storage duration variables in my program?
singletonFoois not thread safe?