#include <iostream>
using namespace std;
class Inner2 {
public:
Inner2() { cout << "Inner2()" << endl; }
};
class Inner1 {
public:
Inner1() : inner2(Inner2()) {
cout << "Inner1()" << endl;
}
Inner2 inner2;
};
Inner1 makeInner1() { return Inner1(); }
class Hoge {
public:
Hoge() : Hoge(makeInner1()) {
cout << "Hoge()" << endl;
}
Hoge(Inner1 &&inner1) : Hoge(std::move(inner1.inner2)) {
cout << "Hoge(Inner1 &&)" << endl;
}
Hoge(Inner2 &&inner2) : inner2(inner2) {
cout << "Hoge(Inner2 &&)" << endl;
}
private:
Inner2 inner2;
};
int main(){
Hoge h;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIElubmVyMiB7CnB1YmxpYzoKCUlubmVyMigpIHsgY291dCA8PCAiSW5uZXIyKCkiIDw8IGVuZGw7IH0KfTsKCmNsYXNzIElubmVyMSB7CnB1YmxpYzoKCUlubmVyMSgpIDogaW5uZXIyKElubmVyMigpKSB7CgkJY291dCA8PCAiSW5uZXIxKCkiIDw8IGVuZGw7Cgl9CglJbm5lcjIgaW5uZXIyOwp9OwoKSW5uZXIxIG1ha2VJbm5lcjEoKSB7IHJldHVybiBJbm5lcjEoKTsgfQoKY2xhc3MgSG9nZSB7CnB1YmxpYzoKCUhvZ2UoKSA6IEhvZ2UobWFrZUlubmVyMSgpKSB7CgkJY291dCA8PCAiSG9nZSgpIiA8PCBlbmRsOwoJfQoJCglIb2dlKElubmVyMSAmJmlubmVyMSkgOiBIb2dlKHN0ZDo6bW92ZShpbm5lcjEuaW5uZXIyKSkgewoJCWNvdXQgPDwgIkhvZ2UoSW5uZXIxICYmKSIgPDwgZW5kbDsKCX0KCQoJSG9nZShJbm5lcjIgJiZpbm5lcjIpIDogaW5uZXIyKGlubmVyMikgewoJCWNvdXQgPDwgIkhvZ2UoSW5uZXIyICYmKSIgPDwgZW5kbDsKCX0KCQpwcml2YXRlOgoJSW5uZXIyIGlubmVyMjsKfTsKCmludCBtYWluKCl7CglIb2dlIGg7CglyZXR1cm4gMDsKfQoK