I am new to c++11 and wrote the following class where I would like it to support std::move
:
class X {
public:
X(int x) : x_(x) {}
~X() {
printf("X(%d) has be released.\n", x_);
}
X(X&&) = default;
X& operator = (X&&) = default;
X(const X&) = delete;
X& operator = (const X&) = delete;
private:
int x_;
};
However, when I compile it with option -std=c++0x
, the compiler complains the following:
queue_test.cc:12: error: ‘X::X(X&&)’ cannot be defaulted
queue_test.cc:13: error: ‘X& X::operator=(X&&)’ cannot be defaulted
My questions are:
X
to have a default move constructor?Thank you,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With