From ec49fbca4cb84651fb2eae5d093d0342f356cf29 Mon Sep 17 00:00:00 2001 From: Krystian Kuzniarek Date: Tue, 13 Aug 2019 22:30:12 +0200 Subject: remove custom implementations of std::is_same --- googlemock/include/gmock/gmock-spec-builders.h | 6 +++--- .../include/gmock/internal/gmock-internal-utils.h | 4 ---- googlemock/test/gmock-internal-utils_test.cc | 18 ++++++------------ googlemock/test/gmock-matchers_test.cc | 2 +- googletest/include/gtest/gtest-matchers.h | 12 +++++++----- googletest/include/gtest/internal/gtest-internal.h | 6 +++--- googletest/include/gtest/internal/gtest-port.h | 16 ---------------- googletest/test/googletest-output-test_.cc | 8 ++++---- googletest/test/gtest-typed-test_test.cc | 17 +++++++++-------- 9 files changed, 33 insertions(+), 56 deletions(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 735a3bc..0d1adda 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include "gmock/gmock-actions.h" @@ -1653,9 +1654,8 @@ class FunctionMocker final : public UntypedFunctionMockerBase { const OnCallSpec* const spec = FindOnCallSpec(args); if (spec == nullptr) { - *os << (internal::type_equals::value ? - "returning directly.\n" : - "returning default value.\n"); + *os << (std::is_void::value ? "returning directly.\n" + : "returning default value.\n"); } else { *os << "taking default action specified at:\n" << FormatFileLocation(spec->file(), spec->line()) << "\n"; diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index ee00479..7bfa54c 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -359,10 +359,6 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers(); template struct is_reference : public false_type {}; template struct is_reference : public true_type {}; -// type_equals::value is non-zero if T1 and T2 are the same type. -template struct type_equals : public false_type {}; -template struct type_equals : public true_type {}; - // 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 diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc index a76e777..cee13e9 100644 --- a/googlemock/test/gmock-internal-utils_test.cc +++ b/googlemock/test/gmock-internal-utils_test.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "gmock/gmock.h" #include "gmock/internal/gmock-port.h" @@ -518,19 +519,12 @@ TEST(TypeTraitsTest, is_reference) { EXPECT_TRUE(is_reference::value); } -TEST(TypeTraitsTest, type_equals) { - EXPECT_FALSE((type_equals::value)); - EXPECT_FALSE((type_equals::value)); - EXPECT_FALSE((type_equals::value)); - EXPECT_TRUE((type_equals::value)); -} - TEST(TypeTraitsTest, remove_reference) { - EXPECT_TRUE((type_equals::type>::value)); - EXPECT_TRUE((type_equals::type>::value)); - EXPECT_TRUE((type_equals::type>::value)); - EXPECT_TRUE((type_equals::type>::value)); + 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 diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 74e9294..a61d040 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -6434,7 +6434,7 @@ class SampleVariantIntString { template friend bool holds_alternative(const SampleVariantIntString& value) { - return value.has_int_ == internal::IsSame::value; + return value.has_int_ == std::is_same::value; } template diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 7711178..0548806 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -42,6 +42,7 @@ #include #include #include +#include #include "gtest/gtest-printers.h" #include "gtest/internal/gtest-internal.h" @@ -299,8 +300,8 @@ class MatcherBase { template explicit MatcherBase( const MatcherInterface* impl, - typename internal::EnableIf< - !internal::IsSame::value>::type* = nullptr) + typename internal::EnableIf::value>::type* = + nullptr) : impl_(new internal::MatcherInterfaceAdapter(impl)) {} MatcherBase(const MatcherBase&) = default; @@ -333,9 +334,10 @@ class Matcher : public internal::MatcherBase { : internal::MatcherBase(impl) {} template - explicit Matcher(const MatcherInterface* impl, - typename internal::EnableIf< - !internal::IsSame::value>::type* = nullptr) + explicit Matcher( + const MatcherInterface* impl, + typename internal::EnableIf::value>::type* = + nullptr) : internal::MatcherBase(impl) {} // Implicit constructor here allows people to write diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 08531d8..240d791 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -977,9 +977,9 @@ template struct IsRecursiveContainerImpl { using value_type = decltype(*std::declval()); using type = - is_same::type>::type, - C>; + std::is_same::type>::type, + C>; }; // IsRecursiveContainer is a unary compile-time predicate that diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 4f887c5..7f00fe7 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -869,16 +869,6 @@ struct StaticAssertTypeEqHelper { enum { value = true }; }; -// Same as std::is_same<>. -template -struct IsSame { - enum { value = false }; -}; -template -struct IsSame { - enum { value = true }; -}; - // Evaluates to the number of elements in 'array'. #define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0])) @@ -1931,12 +1921,6 @@ template const bool bool_constant::value; typedef bool_constant false_type; typedef bool_constant true_type; -template -struct is_same : public false_type {}; - -template -struct is_same : public true_type {}; - template struct IteratorTraits { typedef typename Iterator::value_type value_type; diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 83be568..4f716d8 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -816,9 +816,9 @@ class TypedTestNames { public: template static std::string GetName(int i) { - if (testing::internal::IsSame::value) + if (std::is_same::value) return std::string("char") + ::testing::PrintToString(i); - if (testing::internal::IsSame::value) + if (std::is_same::value) return std::string("int") + ::testing::PrintToString(i); } }; @@ -857,10 +857,10 @@ class TypedTestPNames { public: template static std::string GetName(int i) { - if (testing::internal::IsSame::value) { + if (std::is_same::value) { return std::string("unsignedChar") + ::testing::PrintToString(i); } - if (testing::internal::IsSame::value) { + if (std::is_same::value) { return std::string("unsignedInt") + ::testing::PrintToString(i); } } diff --git a/googletest/test/gtest-typed-test_test.cc b/googletest/test/gtest-typed-test_test.cc index f1ca937..5411832 100644 --- a/googletest/test/gtest-typed-test_test.cc +++ b/googletest/test/gtest-typed-test_test.cc @@ -31,6 +31,7 @@ #include "test/gtest-typed-test_test.h" #include +#include #include #include "gtest/gtest.h" @@ -177,10 +178,10 @@ class TypedTestNames { public: template static std::string GetName(int i) { - if (testing::internal::IsSame::value) { + if (std::is_same::value) { return std::string("char") + ::testing::PrintToString(i); } - if (testing::internal::IsSame::value) { + if (std::is_same::value) { return std::string("int") + ::testing::PrintToString(i); } } @@ -189,13 +190,13 @@ class TypedTestNames { TYPED_TEST_SUITE(TypedTestWithNames, TwoTypes, TypedTestNames); TYPED_TEST(TypedTestWithNames, TestSuiteName) { - if (testing::internal::IsSame::value) { + if (std::is_same::value) { EXPECT_STREQ(::testing::UnitTest::GetInstance() ->current_test_info() ->test_case_name(), "TypedTestWithNames/char0"); } - if (testing::internal::IsSame::value) { + if (std::is_same::value) { EXPECT_STREQ(::testing::UnitTest::GetInstance() ->current_test_info() ->test_case_name(), @@ -311,13 +312,13 @@ class TypeParametrizedTestWithNames : public Test {}; TYPED_TEST_SUITE_P(TypeParametrizedTestWithNames); TYPED_TEST_P(TypeParametrizedTestWithNames, TestSuiteName) { - if (testing::internal::IsSame::value) { + if (std::is_same::value) { EXPECT_STREQ(::testing::UnitTest::GetInstance() ->current_test_info() ->test_case_name(), "CustomName/TypeParametrizedTestWithNames/parChar0"); } - if (testing::internal::IsSame::value) { + if (std::is_same::value) { EXPECT_STREQ(::testing::UnitTest::GetInstance() ->current_test_info() ->test_case_name(), @@ -331,10 +332,10 @@ class TypeParametrizedTestNames { public: template static std::string GetName(int i) { - if (testing::internal::IsSame::value) { + if (std::is_same::value) { return std::string("parChar") + ::testing::PrintToString(i); } - if (testing::internal::IsSame::value) { + if (std::is_same::value) { return std::string("parInt") + ::testing::PrintToString(i); } } -- cgit v0.12