std::initializer_list in C++, Caveats and Improvements -- Bartłomiej Filipek

bw_photo_small.pngDelving 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 of const 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.

Comments (0)

There are currently no comments on this entry.