I have a vector with structs
Struct S {
S( double a, double b ) : a_(a), b_(b) {}
double a_;
double b_;
S(S&&) = default; //ADDED
}
and I use emplace back to add instances of s to the vector
v.emplace_back( x, y );
Since it doesn't seem to be guaranteed that compilers will add a move constructor, I thought there is no harm in adding a default move constructor, so I added the line commented as ADDED. However, this seemed to have disabled the operator= as I get the compile error
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/stl_algo.h:868: error: use of deleted function ‘S& S::operator=(const S&)’
*__result = _GLIBCXX_MOVE(*__first);
^
I dont understand why that is the case. Is my implementation of S(S&&) the wrong way to do it?
EDIT: The error is thrown when using erase-remove
v.erase(std::remove_if(v.begin(), v.end(), deleteIf), v.end());