summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-14 15:58:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-15 08:25:03 +0200
commit3f20471490c61b19fe4222f8c40df255051f6e3d (patch)
tree5caca827ab21537cc02eeaf193bdc41698a4499f /include/o3tl
parent8ae592a7360d5f6a44d5ad2c34d818f638ff94b2 (diff)
use std::unique_ptr in FlatFndBox
and extend o3tl::make_unique to cope with arrays Change-Id: I84caa46ab5060f9777bfe275f229499cb0b407be Reviewed-on: https://gerrit.libreoffice.org/38794 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/make_unique.hxx16
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