mercredi 5 février 2020

Why doesn't c++11 allow direct-list-initialization with auto

My friend told me that

auto x1 = {3}; // x1 is std::initializer_list<int>
auto x2{1, 2}; // error: not a single element
auto x3{3};    // x3 is int

I don't quite understand why auto x2{1, 2}; is illegal, can't it be deduced directly as std::initializer_list<int>?

Aucun commentaire:

Enregistrer un commentaire