From ab8f346b076f76f7770f33437fb5823fa444cb80 Mon Sep 17 00:00:00 2001 From: kuzkry Date: Thu, 29 Aug 2019 14:38:09 -0400 Subject: [PATCH] Googletest export Merge 7f4f58da20e1066a888d3e4bcbef541db798a605 into 90a443f9c2437ca8a682a1ac625eba64e1d74a8a Closes #2395 COPYBARA_INTEGRATE_REVIEW=https://github.com/google/googletest/pull/2395 from kuzkry:custom-type-traits-remove_reference 7f4f58da20e1066a888d3e4bcbef541db798a605 PiperOrigin-RevId: 266189044 --- googlemock/include/gmock/gmock-matchers.h | 5 ++-- .../include/gmock/gmock-spec-builders.h | 4 +-- .../gmock/internal/gmock-internal-utils.h | 4 --- googlemock/test/gmock-internal-utils_test.cc | 12 --------- .../include/gtest/internal/gtest-internal.h | 18 ++----------- googletest/test/gtest_unittest.cc | 25 ------------------- 6 files changed, 6 insertions(+), 62 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index fa50903b..70092157 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1607,9 +1607,8 @@ class PointeeMatcher { template class Impl : public MatcherInterface { public: - typedef - typename PointeeOf::type>::type Pointee; + typedef typename PointeeOf::type>::type>::type Pointee; explicit Impl(const InnerMatcher& matcher) : matcher_(MatcherCast(matcher)) {} diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 0d1adda5..66429dfa 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -1320,8 +1320,8 @@ class ReferenceOrValueWrapper { // Provides nondestructive access to the underlying value/reference. // Always returns a const reference (more precisely, - // const RemoveReference&). The behavior of calling this after - // calling Unwrap on the same object is unspecified. + // const std::add_lvalue_reference::type). The behavior of calling this + // after calling Unwrap on the same object is unspecified. const T& Peek() const { return value_; } diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 1770d5e7..53b6d976 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -336,10 +336,6 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers(); // Type traits. -// remove_reference::type removes the reference from type T, if any. -template struct remove_reference { typedef T type; }; // NOLINT -template struct remove_reference { typedef T type; }; // NOLINT - // Disable MSVC warnings for infinite recursion, since in this case the // the recursion is unreachable. #ifdef _MSC_VER diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc index 67b7077f..7df4078e 100644 --- a/googlemock/test/gmock-internal-utils_test.cc +++ b/googlemock/test/gmock-internal-utils_test.cc @@ -506,18 +506,6 @@ TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) { TestLogWithSeverity("invalid", kWarning, true); } -#endif // GTEST_HAS_STREAM_REDIRECTION - -TEST(TypeTraitsTest, remove_reference) { - EXPECT_TRUE((std::is_same::type>::value)); - EXPECT_TRUE( - (std::is_same::type>::value)); - EXPECT_TRUE((std::is_same::type>::value)); - EXPECT_TRUE((std::is_same::type>::value)); -} - -#if GTEST_HAS_STREAM_REDIRECTION - // Verifies that Log() behaves correctly for the given verbosity level // and log severity. std::string GrabOutput(void(*logger)(), const char* verbosity) { diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 37daf214..3a98ce48 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -856,30 +856,16 @@ template struct CompileAssertTypesEqual { }; -// Removes the reference from a type if it is a reference type, -// otherwise leaves it unchanged. This is the same as -// tr1::remove_reference, which is not widely available yet. -template -struct RemoveReference { typedef T type; }; // NOLINT -template -struct RemoveReference { typedef T type; }; // NOLINT - -// A handy wrapper around RemoveReference that works when the argument -// T depends on template parameters. -#define GTEST_REMOVE_REFERENCE_(T) \ - typename ::testing::internal::RemoveReference::type - // Turns const U&, U&, const U, and U all into U. #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \ - typename std::remove_const::type + typename std::remove_const::type>::type // IsAProtocolMessage::value is a compile-time bool constant that's // true if T is type proto2::Message or a subclass of it. template struct IsAProtocolMessage : public bool_constant< - std::is_convertible::value> { -}; + std::is_convertible::value> {}; // When the compiler sees expression IsContainerTest(0), if C is an // STL-style container class, the first overload of IsContainerTest diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 5020d732..12c5a871 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -262,7 +262,6 @@ using testing::internal::OsStackTraceGetterInterface; using testing::internal::ParseInt32Flag; using testing::internal::RelationToSourceCopy; using testing::internal::RelationToSourceReference; -using testing::internal::RemoveReference; using testing::internal::ShouldRunTestOnShard; using testing::internal::ShouldShard; using testing::internal::ShouldUseColor; @@ -7110,30 +7109,6 @@ TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) { CompileAssertTypesEqual(); } -// Tests that RemoveReference does not affect non-reference types. -TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) { - CompileAssertTypesEqual::type>(); - CompileAssertTypesEqual::type>(); -} - -// Tests that RemoveReference removes reference from reference types. -TEST(RemoveReferenceTest, RemovesReference) { - CompileAssertTypesEqual::type>(); - CompileAssertTypesEqual::type>(); -} - -// Tests GTEST_REMOVE_REFERENCE_. - -template -void TestGTestRemoveReference() { - CompileAssertTypesEqual(); -} - -TEST(RemoveReferenceTest, MacroVersion) { - TestGTestRemoveReference(); - TestGTestRemoveReference(); -} - // Tests GTEST_REMOVE_REFERENCE_AND_CONST_. template