C++11/C++1y 15
■ このスレッドは過去ログ倉庫に格納されています
0148デフォルトの名無しさん
2012/05/05(土) 21:31:04.81using namespace std;
struct X {
const int x;
X(const int& x): x(x) {}
X(const X&) = delete;
X& operator=(const X&) = delete;
X(X&& rhs): x(move(rhs.x)) {
cout << "called X(X&&)" << endl;
}
X& operator=(X&& rhs) {
cout << "called operator=(X&&)" << endl;
return *this = X(move(rhs));
}
};
int main()
{
X a = X(2);
cout << a.x << endl;
}
・・・誰が呼ばれたの?・・・
■ このスレッドは過去ログ倉庫に格納されています