Herb Sutter propose a simple implementation of make_unique()
there: http://herbsutter.com/gotw/_102/
Here it is:
template
Even though variadic templates are not part of VS2012, there are macros built into the header file
that help simulate them.
See this very nice answer which shows how to implement make_unique
in just a few cryptic lines. I confirmed that it works well:
#include
// brings in TEMPLATE macros. #define MAKE_UNIQUE(TEMPLATE_LIST, PADDING_LIST, LIST, COMMA, X1, X2, X3, X4) \ template \ inline std::unique_ptr make_unique(LIST(_TYPE_REFREF_ARG)) \ { \ return std::unique_ptr (new T(LIST(_FORWARD_ARG))); \ } _VARIADIC_EXPAND_0X(MAKE_UNIQUE, , , , ) #undef MAKE_UNIQUE