I'm still new to C++11 thread_local storage. In particular I'm curious about following code:
class foo_t
{
foo_t() { std::cout << "Foo ctor"; }
~foo_t() { std::cout << "Foo dtor"; }
}
thread_local foo_t foo;
void bar() { }
void baz() { }
int main()
{
std::thread t1(bar), t2(baz);
t1.join(); t2.join();
}
Will the ctor/dtor of foo_t be called twice in this example (I mean does the standard requires so)? What if I move bar to other translation unit? What if such unit won't have a declaration of foo_t nor foo?