I have used this pattern before to do module-specific initialization, e.g. at the top of a .cpp file:
static bool isInitialized = []()
{
...//do stuff
return true;
}();
But what about something like:
static MyObject something = []()
{
MyObject ret(...);
ret.x(...)
return ret;
}();
Is it definitive if something will be ret, or will be a copy? I want to avoid copying.
I'm working with VS2017/C++14 mainly, though moving to C++17 soon.