From the standard C ++ 11, 18.9 [support.initlist]:
2 An object of type initializer_list provides access to an array of objects of type const E. [Note: a pair of pointers or a pointer plus length will be obvious representations for initializer_list. initializer_list is used to implement initializer lists, as specified in 8.5.4. Copying the list of initializers does not copy the basic elements. - end of note]
This is similar to finding pointers to objects. You can also make the pointer outlive the object. If you want to make it "safe", take / save the vector of elements.
Copying elements would make it expensive, and therefore no one would use it. Accessible documentation allows you to clearly understand what it is doing.
EDIT:
This is a Stroustrup proposal for initializer_list
: N2100 . Reading can enlighten his design decisions.
source share