Quick A: Because it doesn't have to be. It's "the C++ way" to prefer library solutions, and initializer_list
shows how far you can get with a pure library solution, then the rest of the way with minimal language support to create initializer_list
objects.
Recently on SO:
Why isn't
std::initializer_list
a core-language built-in?It seems to me that it's quite an important feature of C++11 and yet it doesn't have its own reserved keyword (or something alike).
Instead,
initializer_list
it's just a template class from the standard library that has a special, implicit mapping from the new braced-init-list{...}
syntax that's handled by the compiler.At first thought, this solution is quite hacky. ...
Add a Comment
Comments are closed.