You need to provide move operations for your type:
data(data&& other) : l(std::move(other.l)) { } data& operator=(data&& other) { l = std::move(other.l); return *this; }
And, since you add the constructor declared by the user, you will also need the default constructor declared by the user:
data() { }
I understand that your code is correct as it is, in accordance with the final C ++ 11 language standard. Visual C ++ does not fully implement the final specification when move operations are implicitly generated (as in Visual C ++ 2012 RC). The specification, when implicit move operations are generated, has changed dramatically several times during the standardization process.
If you have a class type C
that has any data member that is movable but not copyable, Visual C ++ will not generate an implicit move constructor or move an assignment operator, and the implicit copy constructor and copy assignment operator will be suppressed data item to move only. In other words, if you want aggregate types to be move-only, you must provide the move operations for the aggregation class yourself.
(At least this is my understanding from experimenting with the compiler.)
source share