diff options
| -rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 8 | ||||
| -rw-r--r-- | googletest/include/gtest/gtest-printers.h | 4 | ||||
| -rw-r--r-- | googletest/include/gtest/gtest.h | 2 | ||||
| -rw-r--r-- | googletest/include/gtest/internal/gtest-internal.h | 52 | ||||
| -rw-r--r-- | googletest/test/gtest_unittest.cc | 30 | 
5 files changed, 9 insertions, 87 deletions
| diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index b99fdc36..56804f39 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -128,9 +128,9 @@ class MatcherCastImpl {      return CastImpl(          polymorphic_matcher_or_value,          BooleanConstant< -            internal::ImplicitlyConvertible<M, Matcher<T> >::value>(), +            std::is_convertible<M, Matcher<T> >::value>(),          BooleanConstant< -            internal::ImplicitlyConvertible<M, T>::value>()); +            std::is_convertible<M, T>::value>());    }   private: @@ -268,8 +268,8 @@ class SafeMatcherCastImpl {    template <typename U>    static inline Matcher<T> Cast(const Matcher<U>& matcher) {      // Enforce that T can be implicitly converted to U. -    GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible<T, U>::value), -                          T_must_be_implicitly_convertible_to_U); +    GTEST_COMPILE_ASSERT_((std::is_convertible<T, U>::value), +                          "T must be implicitly convertible to U");      // Enforce that we are not converting a non-reference type T to a reference      // type U.      GTEST_COMPILE_ASSERT_( diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index d6596e48..9048459e 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -232,12 +232,12 @@ template <typename Char, typename CharTraits, typename T>      ::std::basic_ostream<Char, CharTraits>& os, const T& x) {    TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value                                 ? kProtobuf -                               : internal::ImplicitlyConvertible< +                               : std::is_convertible<                                       const T&, internal::BiggestInt>::value                                       ? kConvertibleToInteger                                       :  #if GTEST_HAS_ABSL -                                     internal::ImplicitlyConvertible< +                                     std::is_convertible<                                           const T&, absl::string_view>::value                                           ? kConvertibleToStringView                                           : diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index a0df29e2..3c725751 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -306,7 +306,7 @@ class GTEST_API_ AssertionResult {    explicit AssertionResult(        const T& success,        typename internal::EnableIf< -          !internal::ImplicitlyConvertible<T, AssertionResult>::value>::type* +          !std::is_convertible<T, AssertionResult>::value>::type*        /*enabler*/        = nullptr)        : success_(success) {} diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 8ef69c43..94773df3 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -920,62 +920,14 @@ struct RemoveConst<const T[N]> {  #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \      GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T)) -// ImplicitlyConvertible<From, To>::value is a compile-time bool -// constant that's true iff type From can be implicitly converted to -// type To. -template <typename From, typename To> -class ImplicitlyConvertible { - private: -  // We need the following helper functions only for their types. -  // They have no implementations. - -  // MakeFrom() is an expression whose type is From.  We cannot simply -  // use From(), as the type From may not have a public default -  // constructor. -  static typename AddReference<From>::type MakeFrom(); - -  // These two functions are overloaded.  Given an expression -  // Helper(x), the compiler will pick the first version if x can be -  // implicitly converted to type To; otherwise it will pick the -  // second version. -  // -  // The first version returns a value of size 1, and the second -  // version returns a value of size 2.  Therefore, by checking the -  // size of Helper(x), which can be done at compile time, we can tell -  // which version of Helper() is used, and hence whether x can be -  // implicitly converted to type To. -  static char Helper(To); -  static char (&Helper(...))[2];  // NOLINT - -  // We have to put the 'public' section after the 'private' section, -  // or MSVC refuses to compile the code. - public: -#if defined(__BORLANDC__) -  // C++Builder cannot use member overload resolution during template -  // instantiation.  The simplest workaround is to use its C++0x type traits -  // functions (C++Builder 2009 and above only). -  static const bool value = __is_convertible(From, To); -#else -  // MSVC warns about implicitly converting from double to int for -  // possible loss of data, so we need to temporarily disable the -  // warning. -  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244) -  static const bool value = -      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; -  GTEST_DISABLE_MSC_WARNINGS_POP_() -#endif  // __BORLANDC__ -}; -template <typename From, typename To> -const bool ImplicitlyConvertible<From, To>::value; -  // IsAProtocolMessage<T>::value is a compile-time bool constant that's  // true iff T is type ProtocolMessage, proto2::Message, or a subclass  // of those.  template <typename T>  struct IsAProtocolMessage      : public bool_constant< -  ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value || -  ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> { +  std::is_convertible<const T*, const ::ProtocolMessage*>::value || +  std::is_convertible<const T*, const ::proto2::Message*>::value> {  };  // When the compiler sees expression IsContainerTest<C>(0), if C is an diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 147f0f5c..3b18af64 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -250,7 +250,6 @@ using testing::internal::GetTestTypeId;  using testing::internal::GetTimeInMillis;  using testing::internal::GetTypeId;  using testing::internal::GetUnitTestImpl; -using testing::internal::ImplicitlyConvertible;  using testing::internal::Int32;  using testing::internal::Int32FromEnvOrDie;  using testing::internal::IsAProtocolMessage; @@ -7240,35 +7239,6 @@ TEST(GTestReferenceToConstTest, Works) {    TestGTestReferenceToConst<const std::string&, const std::string&>();  } -// Tests that ImplicitlyConvertible<T1, T2>::value is a compile-time constant. -TEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) { -  GTEST_COMPILE_ASSERT_((ImplicitlyConvertible<int, int>::value), const_true); -  GTEST_COMPILE_ASSERT_((!ImplicitlyConvertible<void*, int*>::value), -                        const_false); -} - -// Tests that ImplicitlyConvertible<T1, T2>::value is true when T1 can -// be implicitly converted to T2. -TEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) { -  EXPECT_TRUE((ImplicitlyConvertible<int, double>::value)); -  EXPECT_TRUE((ImplicitlyConvertible<double, int>::value)); -  EXPECT_TRUE((ImplicitlyConvertible<int*, void*>::value)); -  EXPECT_TRUE((ImplicitlyConvertible<int*, const int*>::value)); -  EXPECT_TRUE((ImplicitlyConvertible<ConversionHelperDerived&, -                                     const ConversionHelperBase&>::value)); -  EXPECT_TRUE((ImplicitlyConvertible<const ConversionHelperBase, -                                     ConversionHelperBase>::value)); -} - -// Tests that ImplicitlyConvertible<T1, T2>::value is false when T1 -// cannot be implicitly converted to T2. -TEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) { -  EXPECT_FALSE((ImplicitlyConvertible<double, int*>::value)); -  EXPECT_FALSE((ImplicitlyConvertible<void*, int*>::value)); -  EXPECT_FALSE((ImplicitlyConvertible<const int*, int*>::value)); -  EXPECT_FALSE((ImplicitlyConvertible<ConversionHelperBase&, -                                      ConversionHelperDerived&>::value)); -}  // Tests IsContainerTest. | 
