An initializer-list is the C++11 way to initialize using curly braces:
#include <vector>
int main()
{
const std::vector<int> v = {1,2,3,4,5};
}
- If a class is a container, give it an initializer-list constructor [1]
- Initialize member variables with the member initializer list [2]
- [1] Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 17.7. Advice. page 525: '[8] If a class is a container, give it an initializer-list constructor'
- [2] Jason Turner, cppbestpractices: Initialize Member Variables with the member initializer list