From 08abb38f46a29fa4040db1ac0b9fd08452438258 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 11 Dec 2018 14:42:44 +0100 Subject: [PATCH] ENH: Add another New() implementation enabled for non default construcible TFunctor so as to get a nice warning (thanks to @aregimbeau for the patch) --- Modules/Core/Functor/include/otbFunctorImageFilter.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Modules/Core/Functor/include/otbFunctorImageFilter.h b/Modules/Core/Functor/include/otbFunctorImageFilter.h index 06de75fa13..7052bcc222 100644 --- a/Modules/Core/Functor/include/otbFunctorImageFilter.h +++ b/Modules/Core/Functor/include/otbFunctorImageFilter.h @@ -310,6 +310,17 @@ public: p->UnRegister(); return p; } + + /** New() macro defined only if TFunction is NOT default constructible + * This will yield an error message since New() can not be implemented in this case. */ + template <typename F = TFunction> static std::enable_if_t<!std::is_default_constructible<F>::value, Pointer> New() + { + static_assert(std::is_default_constructible<F>::value,"Cannot call New() " + "methode as the functor used for the filter creation is not default " + "constructible"); + + return nullptr; + } /** Get the functor object. * -- GitLab