#include <iostream>
#include <vector>
using namespace std;
class MyClass {
public:
MyClass() {
cout << "constructor" << endl;
}
MyClass(MyClass&& c) {
cout << "move constructor" << endl;
data = 0;
}
int data;
};
MyClass foo() {
MyClass c;
c.data = 99999;
return c;
}
MyClass foo1(MyClass c) {
c.data = 50;
return c;
}
int main(int argc, char *argv[])
{
MyClass cl1 = foo(); //почему тут не вызывается move конструктор?
MyClass cl2 = foo1(MyClass());
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIE15Q2xhc3MgewpwdWJsaWM6CiAgICBNeUNsYXNzKCkgewogICAgICAgIGNvdXQgPDwgImNvbnN0cnVjdG9yIiA8PCBlbmRsOwogICAgfQoKICAgIE15Q2xhc3MoTXlDbGFzcyYmIGMpIHsKICAgICAgICBjb3V0IDw8ICJtb3ZlIGNvbnN0cnVjdG9yIiA8PCBlbmRsOwogICAgICAgIGRhdGEgPSAwOwogICAgfQoKICAgIGludCBkYXRhOwp9OwoKCk15Q2xhc3MgZm9vKCkgewogICAgTXlDbGFzcyBjOwogICAgYy5kYXRhID0gOTk5OTk7CiAgICByZXR1cm4gYzsKfQoKTXlDbGFzcyBmb28xKE15Q2xhc3MgYykgewogICAgYy5kYXRhID0gNTA7CiAgICByZXR1cm4gYzsKfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKewogICAgTXlDbGFzcyBjbDEgPSBmb28oKTsgLy/Qv9C+0YfQtdC80YMg0YLRg9GCINC90LUg0LLRi9C30YvQstCw0LXRgtGB0Y8gbW92ZSDQutC+0L3RgdGC0YDRg9C60YLQvtGAPwogICAgTXlDbGFzcyBjbDIgPSBmb28xKE15Q2xhc3MoKSk7CgogICAgcmV0dXJuIDA7Cn0K