This is a continuation of this question but I don't want to use a custom deleter. I have the following interface:
struct Interface {
Interface(const Interface &) = delete;
auto operator=(const Interface &) -> Interface & = delete;
~Interface() = 0;
protected:
Interface() = default;
};
And an implementation:
struct Implementation : public Interface {
Implementation(Pool &p) : m_pool{p} {}
Pool &m_pool;
};
I also have a pool of Implementations:
struct Pool {
auto get() -> std::unique_ptr<Interface>;
std::vector<std::unique_ptr<Interface>> m_objects;
};
My question is if it is possible to have the Implementation
, instantiated as a pointer to Interface
, move itself into the pool when its destructor is called?