Herb Sutter propose a simple implementation of make_unique()
there: http://herbsutter.com/gotw/_102/
Here it is:
template
I know I am late to the party here, but I just came across this. I have been doing this with a one-liner macro (and is VS2012 compatible):
#define MAKE_UNIQUE(T, ...) std::unique_ptr(new T(__VA_ARGS__))
Or less portable, but you can pass in empty params
#define MAKE_UNIQUE(T, ...) std::unique_ptr(new T(##__VA_ARGS__))
Use like this:
// MAKE_UNIQUE takes the type followed by the arguments list ...
std::unique_ptr pPointer = MAKE_UNIQUE(MyClass, param_1, param_2, ..., param_n);