#include <iostream>
#include <string>
struct bar
{
bar(const std::string& str) : _str(str) {}
bar(const bar&) = delete;
bar(bar&& other) : _str(std::move(other._str)) {other._str = "Stolen";}
void print() {std::cout << _str << std::endl;}
std::string _str;
};
struct foo
{
foo(bar& b) : _b(b) {}
~foo() {_b.print();}
bar& _b;
};
bar foobar()
{
bar b("Hello, World!");
foo f(b);
return std::move(b);
}
int main()
{
foobar();
return EXIT_SUCCESS;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKc3RydWN0IGJhcgp7CiAgICBiYXIoY29uc3Qgc3RkOjpzdHJpbmcmIHN0cikgOiBfc3RyKHN0cikge30KICAgIAogICAgYmFyKGNvbnN0IGJhciYpID0gZGVsZXRlOwoKICAgIGJhcihiYXImJiBvdGhlcikgOiBfc3RyKHN0ZDo6bW92ZShvdGhlci5fc3RyKSkge290aGVyLl9zdHIgPSAiU3RvbGVuIjt9CgogICAgdm9pZCBwcmludCgpIHtzdGQ6OmNvdXQgPDwgX3N0ciA8PCBzdGQ6OmVuZGw7fQoKICAgIHN0ZDo6c3RyaW5nIF9zdHI7Cn07CgpzdHJ1Y3QgZm9vCnsKICAgZm9vKGJhciYgYikgOiBfYihiKSB7fQogICAKICAgfmZvbygpIHtfYi5wcmludCgpO30KCiAgIGJhciYgX2I7Cn07CgpiYXIgZm9vYmFyKCkKewogICAgYmFyIGIoIkhlbGxvLCBXb3JsZCEiKTsKICAgIGZvbyBmKGIpOwoKICAgIHJldHVybiBzdGQ6Om1vdmUoYik7Cn0KCmludCBtYWluKCkKewogICAgZm9vYmFyKCk7CgogICAgcmV0dXJuIEVYSVRfU1VDQ0VTUzsKfQ==