Add std::make_unique implementation It's not available in C++11, it was added in C++14.
diff --git a/goo/gmem.h b/goo/gmem.h index 898f339..4dad2d3 100644 --- a/goo/gmem.h +++ b/goo/gmem.h
@@ -25,6 +25,7 @@ #ifndef GMEM_H #define GMEM_H +#include <memory> #include <stdio.h> #include "poppler-config.h" @@ -89,4 +90,37 @@ } #endif +/* Remove this once we switch to C++14 */ +#if __cplusplus < 201400L +namespace std { +template<class T> struct _Unique_if { + typedef unique_ptr<T> _Single_object; +}; + +template<class T> struct _Unique_if<T[]> { + typedef unique_ptr<T[]> _Unknown_bound; +}; + +template<class T, size_t N> struct _Unique_if<T[N]> { + typedef void _Known_bound; +}; + +template<class T, class... Args> inline typename _Unique_if<T>::_Single_object +make_unique(Args&&... args) +{ + return unique_ptr<T>(new T(std::forward<Args>(args)...)); +} + +template<class T> inline typename _Unique_if<T>::_Unknown_bound +make_unique(size_t n) +{ + typedef typename remove_extent<T>::type U; + return unique_ptr<T>(new U[n]()); +} + +template<class T, class... Args> typename _Unique_if<T>::_Known_bound +make_unique(Args&&...) = delete; +} +#endif + #endif