#include <new> #include <type_traits> template<typename T, typename... V> void reuse_inplace(T& obj, V... args) { static_assert(!std::is_const<T>::value, "in-place construction over a const object"); obj.~T(); new(&obj) T(args...); };
Nice. I'll switch to this once I move to VC++2013, as 2012 doesn't support variadic templates.