I have a function foo:
std::vector<T> foo() {
std::vector<T> result;
// populate result
{
/*
for loop with result.push_back().
ignore real code.
*/
}
//
return result; <-- note there without std::move
}
Will it do extra copy if I assign like the following?
const auto v = foo(); <-- will it move the vector by default?
const auto &v = foo(); <-- same question as above, assuming T is movable
Aucun commentaire:
Enregistrer un commentaire