diff --git a/core/foundation/inc/ROOT/RNotFn.hxx b/core/foundation/inc/ROOT/RNotFn.hxx
index 0a84c2a73e5fad492fc404da443aa1f7fdc5b9fc..a6dd13679e37cb84f34db6c6c7df1268fe7abf57 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 244c0957365bb3cbde11c9e1d05ab09d70b830fb..eccabe75e8cdd4dd75fbf63ffabd1727d06bf980 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"