If I do not declare move constructor, the copy one is called, but if I delete the move constructor – compilation error – why?
struct X { X() = default; X(const X& src) { cout << “copy” << endl; } }; int main() { X x1; X x2(move(x1)); } Output: copy struct X { X() = default; X(const X& src) { cout << “copy” << endl; } X(X&& src) = delete; }; int main() { X x1; X x2(move(x1)); […]
C++: if I do not declare move constructor, the copy one is called, but if I delete the move constructor – compilation error – why?
struct X { X() = default; X(const X& src) { cout << “copy” << endl; } }; int main() { X x1; X x2(move(x1)); } Output: copy struct X { X() = default; X(const X& src) { cout << “copy” << endl; } X(X&& src) = delete; }; int main() { X x1; X x2(move(x1)); […]