Fix libc++ bug #20039: 'Constructing std::function from empty compatible std::function results in half-empty state' Thanks to Agustin Berge for the report, and for his and Eric Fiselier's work on a fix.
llvm-svn: 212070
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 38cae6330b3e41fb4c81f6fbdb98b4c8c5b159a8
diff --git a/include/functional b/include/functional
index 38c22f7..416a9a9 100644
--- a/include/functional
+++ b/include/functional
@@ -1421,7 +1421,7 @@
static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
template <class _R2, class ..._Ap>
_LIBCPP_INLINE_VISIBILITY
- static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;}
+ static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;}
template <class _Fp, bool = !is_same<_Fp, function>::value &&
__invokable<_Fp&, _ArgTypes...>::value>