I have been looking at how the initializer_list
is implemented so I found section 18.9 of the standard and found a simple enough looking interface. I thought it wou
The name is important because the standard says it is. The standard needs some way for you to be able to say, "this constructor can be passed a braced-init-list containing a sequence values of the type T". That way was given the name "std::initializer_list
".
You cannot make a class that has all of the language properties of initializer_list
. You can make one that satisfies the conditions of the type specified by section 18.9 of the standard. But you'll notice that the only constructor specified there is a default constructor. The only way to create an initializer_list
with actual elements relies on the compiler, not user-land code.
So you can't replicate everything about initializer_list
. Just as you can't replicate std::type_info
. The C++ standard library is not optional.