#include <new>
#include <iostream>
#include <cstdlib>
#include <memory>
struct s {
static void *operator new(std::size_t size) {
std::cout << "allocate\n";
if (void *ptr = std::malloc(size)) {
return ptr;
}
throw std::bad_alloc();
}
static void operator delete(void *ptr) {
std::cout << "deallocate\n";
std::free(ptr);
}
};
int main() {
std::unique_ptr<s> u(new s);
}
I2luY2x1ZGUgPG5ldz4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPG1lbW9yeT4KCnN0cnVjdCBzIHsKICAgIHN0YXRpYyB2b2lkICpvcGVyYXRvciBuZXcoc3RkOjpzaXplX3Qgc2l6ZSkgewogICAgICAgIHN0ZDo6Y291dCA8PCAiYWxsb2NhdGVcbiI7CiAgICAgICAgaWYgKHZvaWQgKnB0ciA9IHN0ZDo6bWFsbG9jKHNpemUpKSB7CiAgICAgICAgICAgIHJldHVybiBwdHI7CiAgICAgICAgfQogICAgICAgIHRocm93IHN0ZDo6YmFkX2FsbG9jKCk7CiAgICB9CiAgICBzdGF0aWMgdm9pZCBvcGVyYXRvciBkZWxldGUodm9pZCAqcHRyKSB7CiAgICAgICAgc3RkOjpjb3V0IDw8ICJkZWFsbG9jYXRlXG4iOwogICAgICAgIHN0ZDo6ZnJlZShwdHIpOwogICAgfQp9OwoKaW50IG1haW4oKSB7CiAgICBzdGQ6OnVuaXF1ZV9wdHI8cz4gdShuZXcgcyk7Cn0K