I have some compilation problems pushing back elements of type T to a vector when compiling with g++ -std=c++0x.
This is a minimal example:
#include <
The Assignable requirement imposted by the language standard on the standard container elements requires the t = u
expression to be valid even if u
is a const object. The requirement was defined that way since C++98 (see 23.1/4)
You violated that requirement, since your assignment operator does not accept const objects. This immediately mean that your class A
cannot be used as a container element type.
Why it worked in C++03 is rather irrelevant. It worked by accident. It is obvious from the error message that the C++0x implementation of the library uses some C++0x specific features (like std::move
), which is what makes the above requirement to come into play. But anyway, a C++03 implementation (and even C++98 implementation) can also fail to compile for your A
.
Your example with A c = a;
is irrelevant, since it does not use the assignment operator at all (why is it here?).
In order to fix the error you should either accept the parameter by const reference or by value.