AlgoMaster Logo

Initializer Lists (std::initializer_list)

Last Updated: May 17, 2026

15 min read

When you write std::vector<int> v = {10, 20, 30};, the curly braces aren't a special vector feature. They construct a temporary std::initializer_list<int>, and the vector has a constructor that knows how to consume one. This chapter is about what that type actually is, how the compiler hands it to your constructors and functions, and how to teach your own classes to accept the same brace-list syntax. The next chapter (uniform initialization) covers the broader brace-init story; this one stays focused on std::initializer_list itself.

Premium Content

Subscribe to unlock full access to this content and more premium articles.