Delving into the "how it works" and "why use it" of std::initializer_list...
std::initializer_list in C++, Caveats and Improvements
by Bartłomiej Filipek
From the article:
In this article, you’ll learn why
std::initializer_list
has a bad reputation in C++...... We can make the following conclusion:
std::initializer_list
is a “view” type; it references some implementation-dependent and a local array ofconst
values. Use it mainly for passing into functions when you need a variable number of arguments of the same type. If you try to return such lists and pass them around, then you risk lifetime issues. Use with care.Let’s take on another limitation: ...
Add a Comment
Comments are closed.