#include <iostream>
template<typename T>
struct Wrapper
{
T &t;
Wrapper(T &t)
: t(t)
{
}
void rebind(T &t)
{
this->~Wrapper();
new (this) Wrapper(t);
}
};
int main()
{
int x = 7, y = 4;
Wrapper<int> w = x;
std::cout << x << " " << y << std::endl;
w.t = 2;
std::cout << x << " " << y << std::endl;
w.rebind(y);
std::cout << x << " " << y << std::endl;
w.t = 14;
std::cout << x << " " << y << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kc3RydWN0IFdyYXBwZXIKewoJVCAmdDsKCVdyYXBwZXIoVCAmdCkKCTogdCh0KQoJewoJfQoJdm9pZCByZWJpbmQoVCAmdCkKCXsKCQl0aGlzLT5+V3JhcHBlcigpOwoJCW5ldyAodGhpcykgV3JhcHBlcih0KTsKCX0KfTsKCmludCBtYWluKCkKewoJaW50IHggPSA3LCB5ID0gNDsKCVdyYXBwZXI8aW50PiB3ID0geDsKCXN0ZDo6Y291dCA8PCB4IDw8ICIgIiA8PCB5IDw8IHN0ZDo6ZW5kbDsKCXcudCA9IDI7CglzdGQ6OmNvdXQgPDwgeCA8PCAiICIgPDwgeSA8PCBzdGQ6OmVuZGw7Cgl3LnJlYmluZCh5KTsKCXN0ZDo6Y291dCA8PCB4IDw8ICIgIiA8PCB5IDw8IHN0ZDo6ZW5kbDsKCXcudCA9IDE0OwoJc3RkOjpjb3V0IDw8IHggPDwgIiAiIDw8IHkgPDwgc3RkOjplbmRsOwp9Cg==