Reload

Started by
7 comments, last by Prune 10 years, 4 months ago


#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.

"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)

This topic is closed to new replies.

Advertisement