I have a class that holds a std::vector like
struct Mystruct { Mystruct(const std::vector<int>& w): v(w) { std::cout << "Copy constructor :" << v.at(0) << "\n"; } Mystruct(const std::vector<int>&& w): v(w) { std::cout << "Move Constructor :" << v.at(0) << "\n"; } private: std::vector<int> v; }; And I create objects like
int main() { auto x = std::vector<int> {1,2,3}; Mystruct M1(x); Mystruct M2(std::vector<int> {3,2,1}); return 0; } M1 is constructed using the copy constructor and M2 using the "move" constructor, however running in gdb both assignements keep different addresses for v and w, the same happens if I use v (std::move(w)) in the initialization list of the second constructor. so I guess that both assignement are copying the contents of w, is this correct? if its the case, how can I make to move the contents of w instead of copying them
v.data().