Is there an accepted idiom for allocating the backing store for an object in-place but not initializing it? Here's my naive solution:
#include <utility>
template<typename T>
union Slot {
T inst;
Slot() {}
~Slot() {}
template<typename... Args>
T* init(Args&&... args) { return new(&inst) T(std::forward<Args>(args) ...); }
void release() { inst.~T(); }
};
My immediate use case is for an object pool, but it would also be more generally useful.