I cannot compile the attached project because I deleted the move constructors.
Is this the expected behavior? Why does the compiler need the move constructors if it won't use it?
windows-visual studio 2015 14.0.25431.01 update3
#include <string>
#include <sstream>
#include <vector>
class poo {
public:
poo() = default;
poo(poo&&) = delete; //deleted function
virtual ~poo() = default;
poo operator +(const poo &a) const {
poo to_return;
to_return._s += a._s;
return to_return;
//moveconstructors.cpp(14): error C2280: 'poo::poo(poo &&)': attempting to reference a deleted function
}
private:
std::string _s;
};
int main(int, char **) {
poo a;
return 0;
}
EDIT 1: the same result happens after adding "poo (const poo &) = default;"
EDIT 2: the same result happens with windows-visual studio 2019 16.1.0 preview 2.0
EDIT 3: the same result happens after adding/modifying
poo(const std::string &s) : _s(s) {
}
poo operator +(const poo& a) const {
return poo(_s + a._s);
}
EDIT 4: it works fine with vs2019 and /std:c++17