KITFORMA · EDITORIAL ANSWER
Why does vector<int>{10, 2} contain two elements instead of ten twos?
KitForma editorial guide. Brace initialization can select the initializer-list constructor. The two numbers then describe actual elements rather than count and repeated value.
Step-by-step answer
std::vector<int> values(10, 2); when requesting ten copies. Use braces when listing elements deliberately. Review API overloads instead of applying a universal braces-everywhere rule. Similar-looking initialization syntax can communicate different operations.
Assert both size and content in a minimal fixture. This distinction matters when refactoring from parentheses to braces for style: a compiling change can alter behavior. User-defined types with initializer-list constructors can exhibit the same overload preference, so document the intended construction contract.Sources and verification
Sources checked:
Scope: This editorial guide is based on the cited sources and tool behavior. A forum question or a query observed for our site does not establish market search volume, low competition, guaranteed rankings or inadequate answers elsewhere.
This editorial answer was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.