The following two functions produce different assemblies, which tells me they're different. Can someone tell me in what way they are different? And is the function local static variable initialization in func2 thread-safe or not? If the answer depends on the compiler, I'd like to know how would the most common compilers behave with func2.
int func1(int val)
{
const auto impl = [](int v)
{
return v * 10;
};
return impl(val);
}
int func2(int val)
{
static const auto impl = [](int v)
{
return v * 10;
};
return impl(val);
}