C++03 moving a vector into a class member through constructor (move semantics)
I only have access to C++03 and I often want to move a vector into a function the way you can do it in C++11. The question how to do it not to confuse the user of the code too much. So my question is how did programmers do it before C++11. I know that vector can be "moved" using swap function. So here is what I have come up with: class Foo { public: Foo(std::vector<int>& vec) { using std::swap; swap(vec, m_vec); // "move" vec into member vector } private: std::vector<int> m_vec; }; // usage: std::vector<int> v(100, 1337); Foo foo(v); // v.empty() == true The problem with this approach is that