AlgoMaster Logo

Initializer Lists (std::initializer_list)

Last Updated: June 6, 2026

Medium Priority
23 min read

In 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 constructors and functions, and how to make a class 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.