I ran into some code in our project like this:
class A {
public:
A(A&& obj): valid_(false), data_(obj.data_) {}
//...
void print() {
for (auto x : data_) cout<<x<<" ";
cout<<endl;
}
private:
bool valid_;
vector<int> data_;
};
Is this a valid implementation of move constructor? Is it a must to use std::move()
for member variables in move constructor in this case?