The first part of the problem is an outdated compiler, but there is one more: you declared MoveTester::operator= in a suboptimal form - it takes its argument by value, so the copy / move constructor is called in one extra time. Try this version of MoveTester :
struct MoveTester { MoveTester() {} MoveTester(const MoveTester&) { cout << "tester copied " << endl; } MoveTester(MoveTester&&) { cout << "tester moved " << endl; } MoveTester& operator=(const MoveTester&) { cout << "tester copy assignment" << endl; return *this; }
I get the following output :
tester moved tester move assignment tester move assignment
You might get something similar even with GCC 4.7.
As for your second question, the std::vector move constructor is guaranteed by the standard to have constant time complexity. The question is whether the compiler obeys the standard. I believe that the only way to make sure that you need to debug or profile your code.
source share