I’ve got a std::vector<Foo> where Foo is a class containing Foo( Foo&& ) noexcept.
Adding objects to the container works flawlessly, however erasing them using std::vector::erase( iterator ) does not, GCC 4.7 tries to call the assignment operator which I have deleted. The exact error message is:
error: use of deleted function ‘Foobar& Foobar::operator=(const Foobar&)
Edit: Of course std::vector calls the assignment operator, not the copy constructor (you can see that in the error message, too). Fixed it in the description, sorry.
Here’s example source code as requested:
#include <vector>
class Foo {
public:
Foo() {}
Foo( Foo&& other ) noexcept {}
Foo( const Foo& ) = delete;
Foo& operator=( const Foo& ) = delete;
};
int main() {
std::vector<Foo> v;
v.push_back( Foo{} );
v.erase( v.begin() );
}
The problem is that you did not provide a move assignment operator. This is part of the vector Movable requirements for some functions.