It's well-known that you shouldn't use std::move
when returning a local variable:
std::vector<int> return_vector(void)
{
std::vector<int> tmp {1,2,3,4,5};
return std::move(tmp); // DON'T DO THIS
}
But what about the case where your return
expression contains tmp
as a sub-expression?
std::tuple<vector<int>, size_t> return_tuple() const
{
std::vector<int> tmp {1,2,3,4,5};
return std::make_tuple(std::move(tmp), tmp.size());
}