I need to make a member function that has an argument of std::vector<int>
and uses the move
semantics to steal the guts of it and place to a different std::vector<int>
that is a member of class T
.
class T {
std::vector<int> vec;
public:
void setVec(std::vector<int> vec_){ vec = std::move(vec_); }
}
Now my question is; What is the different and implications of having the following interfaces for setVec
and which one should be used?
1 : void setVec(std::vector<int> vec_)
2 : void setVec(std::vector<int>& vec_)
3 : void setVec(std::vector<int>&& vec_)