I'm trying to call some function that includes adding element to vector ( argument passed by value ):
std::vector<Val> vec;
void fun( Val v ) { ... vec.push_back(std::move( v )); ... }
The question is: are there any benefits from move semantics? I'm confused about variable will be "moved" from stack to heap when new vector element constructing: it seems it will be just copied instead.
Aucun commentaire:
Enregistrer un commentaire