#include <iostream>
#include <memory>
#include <exception>
using namespace std;

int randomint() {
  throw std::runtime_error("whoops");
  
  return 4;
}

struct Movable {
 Movable():value(1997){}
 Movable(Movable&& other){std::cout << "move ctor\n"; other.value=0;}
 int value;
};

void byval(Movable x, int y) {
  std::cout << x.value + y << "\n";	
}

int main() {
	
	Movable n;
	try {
		byval(std::move(n), randomint());
	} catch (std::exception& e) {
		std::cout << e.what() << "\n";
	}
	
	std::cout << "intact: " << n.value << "\n";
	return 0;
}