From 0a80845e73d5b6c87c87eec6b5777224542d8bd9 Mon Sep 17 00:00:00 2001 From: Vladimir Goncharov Date: Tue, 7 Jul 2020 19:28:24 +0300 Subject: [PATCH] Fix build under msvc --- googlemock/include/gmock/gmock-matchers.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 36625209e..f2e47efa4 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4734,6 +4734,13 @@ namespace internal { template class ExceptionMatcherImpl { + class NeverThrown { + public: + const char* what() const noexcept { + return "this exception should never be thrown"; + } + }; + public: ExceptionMatcherImpl(Matcher matcher) : matcher_(std::move(matcher)) {} @@ -4764,7 +4771,14 @@ class ExceptionMatcherImpl { } else { return true; } - } catch (const std::exception& err) { + } catch ( + typename std::conditional< + std::is_same< + typename std::remove_cv< + typename std::remove_reference::type>::type, + std::exception>::value, + const NeverThrown&, + const std::exception&>::type const& err) { #if GTEST_HAS_RTTI *listener << "throws an exception of type " << GetTypeName(typeid(err)) << " ";