#include <iostream>
#include <memory>
#include <exception>
using namespace std;
int randomint() {
throw std::runtime_error("whoops");
return 4;
}
void byval(std::unique_ptr<int> x, int y) {
std::cout << *x + y << "\n";
}
int main() {
auto n = std::make_unique<int>(5);
try {
byval(std::move(n), randomint());
} catch (std::exception& e) {
std::cout << e.what() << "\n";
}
if (n) std::cout << "intact: " << *n << "\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgojaW5jbHVkZSA8ZXhjZXB0aW9uPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IHJhbmRvbWludCgpIHsKICB0aHJvdyBzdGQ6OnJ1bnRpbWVfZXJyb3IoIndob29wcyIpOwogIAogIHJldHVybiA0Owp9Cgp2b2lkIGJ5dmFsKHN0ZDo6dW5pcXVlX3B0cjxpbnQ+IHgsIGludCB5KSB7CiAgc3RkOjpjb3V0IDw8ICp4ICsgeSA8PCAiXG4iOwkKfQoKaW50IG1haW4oKSB7CgkKCWF1dG8gbiA9IHN0ZDo6bWFrZV91bmlxdWU8aW50Pig1KTsKCXRyeSB7CgkJYnl2YWwoc3RkOjptb3ZlKG4pLCByYW5kb21pbnQoKSk7Cgl9IGNhdGNoIChzdGQ6OmV4Y2VwdGlvbiYgZSkgewoJCXN0ZDo6Y291dCA8PCBlLndoYXQoKSA8PCAiXG4iOwoJfQoJCglpZiAobikgc3RkOjpjb3V0IDw8ICJpbnRhY3Q6ICIgPDwgKm4gPDwgIlxuIjsKCXJldHVybiAwOwp9