#include <iostream>
#include <memory>
using namespace std;

template <typename T>
struct Destroy {
	void operator()(T *t) const {
		t->destroy();
	}
};

class IRuntime {
public:
	virtual ~IRuntime() = default;
	virtual void destroy() = 0;
};

class IRuntimeImpl : public IRuntime {
public:
	IRuntimeImpl() {
		cout << "created " << this << endl;
	}

	~IRuntimeImpl() override {
		cout << "destroyed " << this << endl;
	}

	void destroy() override {
		delete this;
	}
};

IRuntime* createIRuntime() {
	return new IRuntimeImpl;
}

class Test {

	std::unique_ptr<IRuntime, Destroy<IRuntime>> runtime;

public:
	Test() : runtime(createIRuntime()) {
	}
};

int main() {
	std::unique_ptr<IRuntime, Destroy<IRuntime>> runtime(createIRuntime());
	Test{};
	return 0;
}