This does not compile. Why?
#include <iostream>
#include <vector>
struct test_s {
int a;
test_s& operator=(test_s &&ts) {
a = ts.a;
ts.a = 0;
return *this;
}
};
int main ()
{
std::vector<test_s> v;
test_s ss = std::move(v.front());
return 0;
}
Error(s):
source_file.cpp:20:10: error: call to implicitly-deleted copy constructor of 'test_s'
test_s ss = std::move(v.front());
^ ~~~~~~~~~~~~~~~~~~~~
source_file.cpp:9:13: note: copy constructor is implicitly deleted because 'test_s' has a user-declared move assignment operator
test_s& operator=(test_s &&ts) {
^
1 error generated
Is it possible to move an object from vector(without the call to copy assignment operator)?