Lets say I have the following:
struct Foo
{
Foo() : bar([&]{ doSomething();})
std::function<void(void)> bar;
void doSomething(){};
}
And lets say one thread is constantly calling the bar member of a Foo instance while another thread destructs the Foo instance. Is it possible that a call to bar will result in an invalid function call since the destructor of Foo is called first? Does the destructor of Foo invalidate member function calls before deallocation?
Edit: Sorry I should've been a little more specific, does calling doSomething become undefined before the destructor of bar is called?