From 19c4c9ea097bd7877b793c1e6ce344b47faf0cb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz>
Date: Mon, 2 Apr 2018 23:54:47 +0200
Subject: [PATCH] Math.h: Added workaround for weird clang error

TODO: check later if it is really necessary
---
 src/TNL/Math.h | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/TNL/Math.h b/src/TNL/Math.h
index 0a40b248df..1f754bceca 100644
--- a/src/TNL/Math.h
+++ b/src/TNL/Math.h
@@ -27,12 +27,17 @@ template< typename T1, typename T2, typename ResultType = typename std::common_t
 __cuda_callable__ inline
 ResultType min( const T1& a, const T2& b )
 {
-#if defined(__CUDA_ARCH__)
+#if __cplusplus >= 201402L
+   // std::min is constexpr since C++14 so it can be reused directly
+   return std::min( (ResultType) a, (ResultType) b );
+#else
+ #if defined(__CUDA_ARCH__)
    return ::min( (ResultType) a, (ResultType) b );
-#elif defined(__MIC__)
+ #elif defined(__MIC__)
    return a < b ? a : b;
-#else
+ #else
    return std::min( (ResultType) a, (ResultType) b );
+ #endif
 #endif
 }
 
@@ -46,12 +51,17 @@ template< typename T1, typename T2, typename ResultType = typename std::common_t
 __cuda_callable__
 ResultType max( const T1& a, const T2& b )
 {
-#if defined(__CUDA_ARCH__)
+#if __cplusplus >= 201402L
+   // std::max is constexpr since C++14 so it can be reused directly
+   return std::max( (ResultType) a, (ResultType) b );
+#else
+ #if defined(__CUDA_ARCH__)
    return ::max( (ResultType) a, (ResultType) b );
-#elif defined(__MIC__)
+ #elif defined(__MIC__)
    return a > b ? a : b;
-#else
+ #else
    return std::max( (ResultType) a, (ResultType) b );
+ #endif
 #endif
 }
 
-- 
GitLab