jeudi 20 juin 2019

Lifetime of local static variables in C++11 [duplicate]

This question already has an answer here:

I have a function that is called from multiple threads:

void func()
{
   static MyObject someobject;
   someobject.complexFunc();
}

At program termination, can I assume that someobject is destroyed after the last thread has been terminated? If no, how can I make sure threads don't access it anymore when say std::exit is called?

Thanks

Aucun commentaire:

Enregistrer un commentaire