Commit d2d2d5a7 authored by Julien Michel's avatar Julien Michel
Browse files

Merge branch 'default_functor_filter' into 'develop'

Add DefaultConstructibleFunctorImageFilter in OTBFunctor module

See merge request !310
parents c3fa194e 6b7043fc
......@@ -298,6 +298,29 @@ public:
/** Run-time type information (and related methods). */
itkTypeMacro(FunctorImageFilter, VariadicInputsImageFilter);
/** New() macro defined only if TFunction is default constructible */
template <typename F = TFunction> static std::enable_if_t<std::is_default_constructible<F>::value, Pointer> New()
// Explicit default construct
FunctorType f;
// Create a filter out of it
Pointer p = new Self(f, {{0,0}});
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() "
"function as the functor used for the filter creation is not default "
return nullptr;
/** Get the functor object.
......@@ -417,7 +440,6 @@ template <typename Functor, typename TNameMap = void> auto NewFunctorFilter(Func
return NewFunctorFilter<FunctorType,TNameMap>(decoratedF,radius);
}// namespace otb
......@@ -162,6 +162,11 @@ template <typename TOut,typename TIn> struct TestOperatorVoidReturn
res = filter1->GetVariadicNamedInput(tag{});
// Test static New() operator
auto oldStyleNewFilter = FunctorImageFilter<decltype(functor)>::New();
// Hack to silent -Wunused-but-set-variable
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment