From 83f01c0b85106dd5c65bdb7bb3cc3c98dc264720 Mon Sep 17 00:00:00 2001
From: Axel Naumann <Axel.Naumann@cern.ch>
Date: Tue, 9 Apr 2019 11:38:51 +0200
Subject: [PATCH] [foundation] libC++ does not set __cpp_lib_not_fn:

Instead, test for libC++ and language version.
This fixes MacOS builds with >=C++14 and tests enabled.
---
 core/foundation/inc/ROOT/RNotFn.hxx | 8 ++++++--
 core/foundation/test/testNotFn.cxx  | 4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/core/foundation/inc/ROOT/RNotFn.hxx b/core/foundation/inc/ROOT/RNotFn.hxx
index 0a84c2a73e5..a6dd13679e3 100644
--- a/core/foundation/inc/ROOT/RNotFn.hxx
+++ b/core/foundation/inc/ROOT/RNotFn.hxx
@@ -16,8 +16,12 @@
 
 #include <functional>
 
-// Backport if not_fn is not available
-#ifndef __cpp_lib_not_fn
+// Backport if not_fn is not available.
+// libc++ does not define __cpp_lib_not_fn.
+// Assume we have not_fn if libc++ is compiled with C++14 and up.
+#if !defined(__cpp_lib_not_fn) && !(defined(_LIBCPP_VERSION) && __cplusplus > 201103L)
+
+#define R__NOTFN_BACKPORT
 
 #include <type_traits> // std::decay
 #include <utility>     // std::forward, std::declval
diff --git a/core/foundation/test/testNotFn.cxx b/core/foundation/test/testNotFn.cxx
index 244c0957365..eccabe75e8c 100644
--- a/core/foundation/test/testNotFn.cxx
+++ b/core/foundation/test/testNotFn.cxx
@@ -1,6 +1,8 @@
 #include "ROOT/RNotFn.hxx"
 
-#ifndef __cpp_lib_not_fn
+// libc++ does not define __cpp_lib_not_fn.
+// Assume we have not_fn if
+#if defined(R__NOTFN_BACKPORT)
 
 #include "gtest/gtest.h"
 
-- 
GitLab