mardi 17 avril 2018

Why does std::vector constructor from initializer list allows optional comma in C++11?

Follow up question. Following code compiles:

std::vector<int> v{ {1,3}, };

v contains 1, 3. Optional comma denotes that I can continue filling list with element like this:

std::vector<int> v{ {1,3},{1,3} };

This code obviously doesn't compile since container type is int. Waht is purpose of optional comma it above case?

Aucun commentaire:

Enregistrer un commentaire