From: Daniel Arndt Date: Sat, 10 Feb 2018 14:20:03 +0000 (+0100) Subject: Implement std_cxx14::make_unique also for unbounded C-style arrays X-Git-Tag: v9.0.0-rc1~425^2~12 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1eca18e8562d82e833b6f612951aaa7bddd83f1a;p=dealii.git Implement std_cxx14::make_unique also for unbounded C-style arrays --- 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