#include <iostream>
using namespace std;
class A
{
public:
A() { }
~A() noexcept(false) { throw exception(); }
void* operator new ( std::size_t count )
{
cout << "hi" << endl;
return ::operator new(count);
}
void operator delete ( void* ptr)
{
cout << "bye" << endl;
return ::operator delete(ptr);
}
};
int main() {
A* a = new A();
try
{
delete a;
}
catch(...)
{
cout << "eek" << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjbGFzcyBBCnsKcHVibGljOgoJQSgpIHsgfQoJfkEoKSBub2V4Y2VwdChmYWxzZSkgeyB0aHJvdyBleGNlcHRpb24oKTsgfQoJdm9pZCogb3BlcmF0b3IgbmV3ICAoIHN0ZDo6c2l6ZV90IGNvdW50ICkKCXsKCQljb3V0IDw8ICJoaSIgPDwgZW5kbDsKCQlyZXR1cm4gOjpvcGVyYXRvciBuZXcoY291bnQpOwoJfQoJdm9pZCBvcGVyYXRvciBkZWxldGUgICggdm9pZCogcHRyKQoJewoJCWNvdXQgPDwgImJ5ZSIgPDwgZW5kbDsKCQlyZXR1cm4gOjpvcGVyYXRvciBkZWxldGUocHRyKTsKCX0KfTsKCmludCBtYWluKCkgewoJQSogYSA9IG5ldyBBKCk7Cgl0cnkKCXsKCQlkZWxldGUgYTsKCX0KCWNhdGNoKC4uLikKCXsKCQljb3V0IDw8ICJlZWsiIDw8IGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==