dimanche 9 août 2020

What's the limit of the list initializer in C++?

I read in some articles the limit of the list initialization is when we need to initialize a standard container (deque, array, etc) but for vector is ok :

std :: vector < int > v { 10 , 20 };  // ok

But for the others standard container the list initialization isn't accepted.

The other problem is when we use an iterator:

std :: vector u {std :: istream_iterator < int > (fs), std :: istream_iterator < int > ()};

the deduction of the type of u is a std::vector<std::istream_iterator<int>> and not vector as wanted.

There are another limit of the utilisation of uniform initializer ?

Aucun commentaire:

Enregistrer un commentaire