See the following codes : vector<int> v1{1,2,3}; vector<int> v2 = {1,2,3};
My question is :
- Is there any difference between the two ? I know the first one must be list initialization, but how about the second ?
- 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