From 1eca18e8562d82e833b6f612951aaa7bddd83f1a Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 10 Feb 2018 15:20:03 +0100 Subject: [PATCH] Implement std_cxx14::make_unique also for unbounded C-style arrays --- include/deal.II/base/std_cxx14/memory.h | 30 ++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/include/deal.II/base/std_cxx14/memory.h b/include/deal.II/base/std_cxx14/memory.h index e7f6d82bf5..6970f5a069 100644 --- a/include/deal.II/base/std_cxx14/memory.h +++ b/include/deal.II/base/std_cxx14/memory.h @@ -30,15 +30,39 @@ namespace std_cxx14 #ifdef DEAL_II_WITH_CXX14 using std::make_unique; #else + namespace internal + { + template + struct is_bounded_array + { + static constexpr bool value = false; + }; + + template + struct is_bounded_array + { + static constexpr bool value = true; + }; + } + template inline - std::unique_ptr + typename std::enable_if::value, std::unique_ptr >::type make_unique(Args &&... constructor_arguments) { - static_assert(!std::is_array::value, - "This function is not implemented for array types."); return std::unique_ptr(new T(std::forward(constructor_arguments)...)); } + + template + inline + typename std::enable_if::value, std::unique_ptr >::type + make_unique(std::size_t n) + { + static_assert(!internal::is_bounded_array::value, + "This function is not implemented for bounded array types."); + return std::unique_ptr(new typename std::remove_extent::type [n]); + } + #endif } DEAL_II_NAMESPACE_CLOSE -- 2.39.5