The std::initializer_list is mostly used as class constructors/functions argument in order to copy the list elements into another container. But what about creating a global object using std::initializer_list? E.g.:
struct ElemType {
const char* name;
bool flag;
};
std::initializer_list<ElemType> MyGlobalData = { {"One",true}, {"Two",false} };
If to look at the std::initializer_list template definition (checked in Visual Studio 2017), it contains only 2 data members: const _Elem *_First and _Last.
It means that the initializer list data should be stored in an automatic variable. What is its lifetime in this case?
Such example tested in Visual Studio 2017 looks working good. But I doubt whether this behaviour corresponds to the latest C++ standard.