mardi 26 juillet 2016

The initializer list in c++

See the following codes : vector<int> v1{1,2,3}; vector<int> v2 = {1,2,3};

My question is :

  1. Is there any difference between the two ? I know the first one must be list initialization, but how about the second ?
  2. Because there is a assign sign for the second, it makes me think that the compiler will use the initializer_list to create an temp vector first, then it use copy constructor to copy the temp vector to v2. Is this the fact ?

Aucun commentaire:

Enregistrer un commentaire