If I initalize a lambda like this ...
void f()
{
int i;
static
auto lambda = [&i]()
{
cout << &i << endl;
};
// volatile to prevent inline-optimizations
function<void()> fn( lambda ), *volatile pFn = &fn;
(*pFn)();
}
... the lambda is initialized once with the first function-call (aside tha this doesn't make sense since &i could be different for each fn()-call but remain static for the lambda). But does this happen synchronized, i.e. do I not have to guard this initialization myself with a mutex ?