#include <cstddef>
#include <new>
#include <iostream>
#include <initializer_list>
class Allocator {
public:
static Allocator createOnStack() {
return {};
}
~Allocator() {
std::cout << "Destructed " << --i << std::endl;
}
protected:
Allocator() {
std::cout << "Created " << i++ << std::endl;
}
Allocator(const Allocator&) = delete;
static int i;
};
int Allocator::i = 0;
Allocator g() {
Allocator&& a = Allocator::createOnStack();
//return a;
}
void f() {
}
Allocator&& global = Allocator::createOnStack();
int main() {
Allocator&& a = Allocator::createOnStack();
const Allocator& b = Allocator::createOnStack();
return 0;
//Allocator* b = new Allocator{Allocator::createOnStack()};
//Allocator* c = ::new (nullptr) Allocator;
}
I2luY2x1ZGUgPGNzdGRkZWY+CiNpbmNsdWRlIDxuZXc+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGluaXRpYWxpemVyX2xpc3Q+CgpjbGFzcyBBbGxvY2F0b3IgewpwdWJsaWM6CiAgc3RhdGljIEFsbG9jYXRvciBjcmVhdGVPblN0YWNrKCkgewogICAgcmV0dXJuIHt9OwogIH0KICB+QWxsb2NhdG9yKCkgewogICAgc3RkOjpjb3V0IDw8ICJEZXN0cnVjdGVkICIgPDwgLS1pIDw8IHN0ZDo6ZW5kbDsKICB9CiAgCnByb3RlY3RlZDoKICBBbGxvY2F0b3IoKSB7CiAgICBzdGQ6OmNvdXQgPDwgIkNyZWF0ZWQgIiA8PCBpKysgPDwgc3RkOjplbmRsOwogIH0KICBBbGxvY2F0b3IoY29uc3QgQWxsb2NhdG9yJikgPSBkZWxldGU7CiAgc3RhdGljIGludCBpOwp9OwoKaW50IEFsbG9jYXRvcjo6aSA9IDA7CgpBbGxvY2F0b3IgZygpIHsKICBBbGxvY2F0b3ImJiBhID0gQWxsb2NhdG9yOjpjcmVhdGVPblN0YWNrKCk7CiAgLy9yZXR1cm4gYTsKfQoKdm9pZCBmKCkgewp9CgpBbGxvY2F0b3ImJiBnbG9iYWwgPSBBbGxvY2F0b3I6OmNyZWF0ZU9uU3RhY2soKTsK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