#include <memory>
#include <iostream>
struct Die {
~Die () {
std:: cout << "dead" << std::endl;
}
};
union Devil {
std::unique_ptr<Die> ptr;
Devil () {
// initialise that later
}
~Devil() {
// .. No idea what I'm doing
}
int b;
};
int main () {
// ...
Devil in_detail;
in_detail.ptr = std::make_unique<Die>();
in_detail.b = 42;
}
I2luY2x1ZGUgPG1lbW9yeT4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IERpZSB7CiAgfkRpZSAoKSB7CiAgICBzdGQ6OiBjb3V0IDw8ICJkZWFkIiA8PCBzdGQ6OmVuZGw7CiAgfQp9OwoKdW5pb24gRGV2aWwgewogIHN0ZDo6dW5pcXVlX3B0cjxEaWU+IHB0cjsKICBEZXZpbCAoKSB7CiAgICAvLyBpbml0aWFsaXNlIHRoYXQgbGF0ZXIKICB9CiAgfkRldmlsKCkgewogICAgLy8gLi4gTm8gaWRlYSB3aGF0IEknbSBkb2luZwogIH0KICBpbnQgYjsKfTsKCmludCBtYWluICgpIHsKLy8gLi4uCkRldmlsIGluX2RldGFpbDsKaW5fZGV0YWlsLnB0ciA9IHN0ZDo6bWFrZV91bmlxdWU8RGllPigpOwppbl9kZXRhaWwuYiA9IDQyOwp9