summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-14 15:58:42 +0200
committerAndras Timar <andras.timar@collabora.com>2021-05-10 16:17:25 +0200
commitf23b9dfeeba15d25e9c8272fc576e9730f374d6b (patch)
treeed9cdc8e814db3a2c85c68d0cef6b3af13146485
parentbb3979240d04a465ad6c300d30a987cc260011dc (diff)
use std::unique_ptr in FlatFndBox [only make_unique.hxx]
and extend o3tl::make_unique to cope with arrays Reviewed-on: https://gerrit.libreoffice.org/38794 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 3f20471490c61b19fe4222f8c40df255051f6e3d) Change-Id: I84caa46ab5060f9777bfe275f229499cb0b407be
-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