diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gmock/gmock-matchers.h | 11 | ||||
-rw-r--r-- | include/gmock/internal/gmock-port.h | 30 |
2 files changed, 14 insertions, 27 deletions
diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h index 9e97866a..7266fba7 100644 --- a/include/gmock/gmock-matchers.h +++ b/include/gmock/gmock-matchers.h @@ -236,6 +236,14 @@ class PolymorphicMatcher { public: explicit PolymorphicMatcher(const Impl& impl) : impl_(impl) {} + // Returns a mutable reference to the underlying matcher + // implementation object. + Impl& mutable_impl() { return impl_; } + + // Returns an immutable reference to the underlying matcher + // implementation object. + const Impl& impl() const { return impl_; } + template <typename T> operator Matcher<T>() const { return Matcher<T>(new MonomorphicImpl<T>(impl_)); @@ -273,11 +281,12 @@ class PolymorphicMatcher { // doesn't need to customize it. ExplainMatchResultTo(impl_, x, os); } + private: const Impl impl_; }; - const Impl impl_; + Impl impl_; }; // Creates a matcher from its implementation. This is easier to use diff --git a/include/gmock/internal/gmock-port.h b/include/gmock/internal/gmock-port.h index 5b00a41a..6bee9966 100644 --- a/include/gmock/internal/gmock-port.h +++ b/include/gmock/internal/gmock-port.h @@ -75,33 +75,11 @@ namespace testing { namespace internal { -// For Windows, check the compiler version. At least VS 2005 SP1 is +// For MS Visual C++, check the compiler version. At least VS 2003 is // required to compile Google Mock. -#if GTEST_OS_WINDOWS - -#if _MSC_VER < 1400 -#error "At least Visual Studio 2005 SP1 is required to compile Google Mock." -#elif _MSC_VER == 1400 - -// Unfortunately there is no unique _MSC_VER number for SP1. So for VS 2005 -// we have to check if it has SP1 by checking whether a bug fixed in SP1 -// is present. The bug in question is -// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101702 -// where the compiler incorrectly reports sizeof(poiter to an array). - -class TestForSP1 { - private: // GCC complains if x_ is used by sizeof before defining it. - static char x_[100]; - // VS 2005 RTM incorrectly reports sizeof(&x) as 100, and that value - // is used to trigger 'invalid negative array size' error. If you - // see this error, upgrade to VS 2005 SP1 since Google Mock will not - // compile in VS 2005 RTM. - static char Google_Mock_requires_Visual_Studio_2005_SP1_or_later_to_compile_[ - sizeof(&x_) != 100 ? 1 : -1]; -}; - -#endif // _MSC_VER -#endif // GTEST_OS_WINDOWS +#if defined(_MSC_VER) && _MSC_VER < 1310 +#error "At least Visual C++ 2003 (7.1) is required to compile Google Mock." +#endif // Use implicit_cast as a safe version of static_cast or const_cast // for upcasting in the type hierarchy (i.e. casting a pointer to Foo |