From 12fbcfa8c429c6677b4a79ce5367e8fb1f74befe Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@cnes.fr>
Date: Tue, 27 Nov 2018 13:42:47 +0100
Subject: [PATCH] COMP: Attempt to fix VSC compiling error (and a bit of code
 factorization)

---
 .../Functor/include/otbFunctorImageFilter.h   | 19 ++++++++++++++++---
 .../Functor/include/otbFunctorImageFilter.hxx |  4 +++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Modules/Core/Functor/include/otbFunctorImageFilter.h b/Modules/Core/Functor/include/otbFunctorImageFilter.h
index 073944cf4d..3d46b8633b 100644
--- a/Modules/Core/Functor/include/otbFunctorImageFilter.h
+++ b/Modules/Core/Functor/include/otbFunctorImageFilter.h
@@ -118,6 +118,20 @@ template <class T> struct ImageTypeDeduction<itk::VariableLengthVector<T>>
 /// that has std::remove_cvref)
 template <typename T> using RemoveCVRef = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
 
+/**
+* \struct RetrieveOperator
+*
+* \brief Struct to retrieve the operator type
+* 
+* \tparam T the type to retrieve operator() from
+*
+*/
+template <typename T> struct RetrieveOperator
+{
+  static_assert(std::is_class<T>::value || std::is_function<T>::value, "T is not a class or function");
+  using Type = decltype(&T::operator());
+};
+
 /**
 * \struct FunctorFilterSuperclassHelper 
 * \brief Struct allowing to derive the superclass prototype for the
@@ -130,7 +144,7 @@ template <typename T> using RemoveCVRef = typename std::remove_cv<typename std::
 * - InputHasNeighborhood a tuple of N false_type or true_type to denote
 * - if Ith arg of operator() expects a neighborhood.
 */
-template <typename T, typename TNameMap> struct FunctorFilterSuperclassHelper : public FunctorFilterSuperclassHelper<decltype(&std::remove_reference<T>::type::operator()),TNameMap> {};
+template <typename T, typename TNameMap> struct FunctorFilterSuperclassHelper : public FunctorFilterSuperclassHelper<typename RetrieveOperator<T>::Type,TNameMap> {};
 
 namespace functor_filter_details
 {
@@ -362,11 +376,10 @@ template <typename Functor, typename TNameMap> auto NewFunctorFilter(Functor f,
  * It is used internally in NewFunctorFilter version with
  * numberOfOutputBands parameter.
  */ 
-template <typename F> struct NumberOfOutputBandsDecorator : F
+template <typename F> struct NumberOfOutputBandsDecorator : public F
 {
 public:
   constexpr NumberOfOutputBandsDecorator(F t, unsigned int nbComp) : F(t), m_NumberOfOutputBands(nbComp) {}
-  using F::operator();
 
   constexpr size_t OutputSize(...) const
   {
diff --git a/Modules/Core/Functor/include/otbFunctorImageFilter.hxx b/Modules/Core/Functor/include/otbFunctorImageFilter.hxx
index f7b9950ae9..add3fadcc4 100644
--- a/Modules/Core/Functor/include/otbFunctorImageFilter.hxx
+++ b/Modules/Core/Functor/include/otbFunctorImageFilter.hxx
@@ -141,7 +141,9 @@ template <typename T> struct GetProxy<itk::ConstNeighborhoodIterator<T> >
 }
 };
 
-template <class Oper> struct OperProxy : public OperProxy<decltype(&std::remove_reference<Oper>::type::operator())> {};
+/// Proxy for operator (dispatch between void operator()(Out &
+/// out,...) and Out operator()(...)
+template <class Oper> struct OperProxy : public OperProxy<typename RetrieveOperator<Oper>::Type> {};
 
 template<class Out, class ... In> struct OperProxy<Out(*)(In...)>
 {
-- 
GitLab