I have a class
class Person {
// some other fields for this object
std::vector<string> relatives;
}
then a util function which returns a list of Person
std::vector<Person> getSomePerson() {
// implementation details...
}
Now I want to loop through:
for (auto&& p: getSomePerson()) { <---- do I need the rvalue reference???
// use p
some_other_vector.insert(
std::make_move_iterator(p.relatives.begin()),
std::make_move_iterator(p.relatives.end())
)
}
Question: do I need the rvalue reference? Does it make any difference than using simple reference here?