From d11d66a2feca0209be75e24efb9e8ef101f4e05f Mon Sep 17 00:00:00 2001
From: Luc Hermitte <luc.hermitte@csgroup.eu>
Date: Wed, 2 Sep 2020 19:49:42 +0200
Subject: [PATCH] COMP: Work around MSVC not C++14 compliant

---
 Modules/Core/Common/include/otbInterval.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Modules/Core/Common/include/otbInterval.h b/Modules/Core/Common/include/otbInterval.h
index 39ea6344c3..f37c2c0434 100644
--- a/Modules/Core/Common/include/otbInterval.h
+++ b/Modules/Core/Common/include/otbInterval.h
@@ -47,7 +47,9 @@ public:
   constexpr Interval(IndexType l, IndexType u) noexcept
     : m_lower(l), m_upper(u)
     {
+#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304
       assert(l <= u);
+#endif
     }
 
   /** Alternate factory function from a position and a length. */
@@ -76,10 +78,17 @@ public:
   friend constexpr Interval intersect(
       Interval const& lhs, Interval const& rhs) noexcept
   {
+#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304
     auto const low = std::max(lhs.lower(), rhs.lower());
     auto const upp = std::min(lhs.upper(), rhs.upper());
 
     return low <= upp ? Interval{low, upp} : Interval{0,0};
+#else
+    // MSVC version supported is not C++14 compliant
+    return std::max(lhs.lower(), rhs.lower()) <= std::min(lhs.upper(), rhs.upper())
+      ? Interval{std::max(lhs.lower(), rhs.lower()), std::min(lhs.upper(), rhs.upper())}
+      : Interval{0,0};
+#endif
   }
 
   /** Stream inserter for intervals.
-- 
GitLab