diff options
Diffstat (limited to 'include/o3tl/make_unique.hxx')
-rw-r--r-- | include/o3tl/make_unique.hxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/o3tl/make_unique.hxx b/include/o3tl/make_unique.hxx index 2be03e9dc9cf..40658f5734d4 100644 --- a/include/o3tl/make_unique.hxx +++ b/include/o3tl/make_unique.hxx @@ -12,6 +12,7 @@ #include <memory> #include <utility> +#include <type_traits> namespace o3tl { @@ -27,6 +28,21 @@ typename std::unique_ptr<T> make_unique(Args&& ... args) return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } +/** + * for arrays + */ +template <class T> +typename std::enable_if +< + std::is_array<T>::value, + std::unique_ptr<T> +>::type +make_unique(std::size_t n) +{ + typedef typename std::remove_extent<T>::type RT; + return std::unique_ptr<T>(new RT[n]); +} + } #endif |