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_listhas a bad reputation in C++...
... We can make the following conclusion:
std::initializer_listis a “view” type; it references some implementation-dependent and a local array of
constvalues. 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 CommentComments are closed.