Seems it is always good to use std::move to avoid copy operation when necessary.
But I was just wonder, if too many std::move on local variables could cause stack overflow? Because there is no copy happen when using the std::move and I guess the rValueTest will not be destroyed and will remain on the same stack location:
std::vector<int> myArray;
for(int i =0; i<INT_MAX; ++i)
{
int rValueTest = -1;
myArray.push_back(std::move(rValueTest));
}
Aucun commentaire:
Enregistrer un commentaire