diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 7407e119e..603a5029f 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -821,7 +821,11 @@ class [[nodiscard]] IsNullMatcher { template bool MatchAndExplain(const Pointer& p, MatchResultListener* /* listener */) const { - return p == nullptr; + if constexpr (std::is_function_v) { + return false; + } else { + return p == nullptr; + } } void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } @@ -835,7 +839,11 @@ class [[nodiscard]] NotNullMatcher { template bool MatchAndExplain(const Pointer& p, MatchResultListener* /* listener */) const { - return p != nullptr; + if constexpr (std::is_function_v) { + return true; + } else { + return p != nullptr; + } } void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }