From e288dc5609ea04a9f7be9bd7015722f8150bed0c Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Wed, 22 Apr 2020 18:49:42 +0200 Subject: [PATCH] [memory] fix some more constructors in StorageProvider --- dune/xt/common/memory.hh | 10 ++++++---- dune/xt/functions/base/function-as-flux-function.hh | 6 +----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dune/xt/common/memory.hh b/dune/xt/common/memory.hh index 484d0de10..c84c62b39 100644 --- a/dune/xt/common/memory.hh +++ b/dune/xt/common/memory.hh @@ -86,7 +86,7 @@ public: {} explicit ConstAccessByPointer(std::unique_ptr<const T>&& tt) - : tt_(tt) + : tt_(std::move(tt)) {} explicit ConstAccessByPointer(std::shared_ptr<const T> tt) @@ -186,7 +186,7 @@ public: {} explicit AccessByPointer(std::unique_ptr<T>&& tt) - : tt_(tt) + : tt_(std::move(tt)) {} explicit AccessByPointer(std::shared_ptr<T> tt) @@ -318,7 +318,9 @@ public: : storage_(new internal::ConstAccessByPointer<T>(tt)) {} - explicit ConstStorageProvider(T&& tt) + // We have to disable this constructor if T is not a complete type to avoid compilation failures + template <class S, typename std::enable_if_t<std::is_constructible<T, S&&>::value, bool> = true> + explicit ConstStorageProvider(S&& tt) : storage_(new internal::ConstAccessByValue<T>(std::move(tt))) {} @@ -327,7 +329,7 @@ public: {} explicit ConstStorageProvider(std::unique_ptr<const T>&& tt) - : storage_(tt) + : storage_(new internal::ConstAccessByPointer<T>(std::move(tt))) {} ConstStorageProvider(const ConstStorageProvider<T>& other) diff --git a/dune/xt/functions/base/function-as-flux-function.hh b/dune/xt/functions/base/function-as-flux-function.hh index c3ddc8186..234a3438e 100644 --- a/dune/xt/functions/base/function-as-flux-function.hh +++ b/dune/xt/functions/base/function-as-flux-function.hh @@ -40,11 +40,7 @@ public: : function_storage_(function) {} - StateFunctionAsFluxFunctionWrapper(const FunctionType*&& function_ptr) - : function_storage_(std::move(function_ptr)) - {} - - StateFunctionAsFluxFunctionWrapper(std::unique_ptr<FunctionType>&& function_ptr) + StateFunctionAsFluxFunctionWrapper(std::unique_ptr<const FunctionType>&& function_ptr) : function_storage_(std::move(function_ptr)) {} -- GitLab