From cf61803f59cf29251bd37c5e6e012f350b46040f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Sat, 28 Mar 2020 13:57:12 +0000 Subject: [PATCH] Bug 1625138 - Part 5: Replace mozilla::IsDefaultConstructible with std::is_default_constructible. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D68359 --- mfbt/Result.h | 4 +- mfbt/TypeTraits.h | 38 -------------- mfbt/tests/TestTypeTraits.cpp | 99 ----------------------------------- 3 files changed, 2 insertions(+), 139 deletions(-) diff --git a/mfbt/Result.h b/mfbt/Result.h index d061a5e137a9c..b02638e78839d 100644 --- a/mfbt/Result.h +++ b/mfbt/Result.h @@ -272,8 +272,8 @@ struct SelectResultImpl { ? PackingStrategy::NullIsOk : (detail::HasFreeLSB::value && detail::HasFreeLSB::value) ? PackingStrategy::LowBitTagIsError - : (IsDefaultConstructible::value && - IsDefaultConstructible::value && + : (std::is_default_constructible_v && + std::is_default_constructible_v && IsPackableVariant::value) ? PackingStrategy::PackedVariant : PackingStrategy::Variant; diff --git a/mfbt/TypeTraits.h b/mfbt/TypeTraits.h index a2fa5df38b845..cb046e8ffd5f0 100644 --- a/mfbt/TypeTraits.h +++ b/mfbt/TypeTraits.h @@ -468,44 +468,6 @@ struct IsUnsigned : detail::IsUnsignedHelper {}; namespace detail { -struct DoIsDefaultConstructibleImpl { - template - static TrueType test(int); - template - static FalseType test(...); -}; - -template -struct IsDefaultConstructibleImpl : public DoIsDefaultConstructibleImpl { - typedef decltype(test(0)) Type; -}; - -} // namespace detail - -/** - * IsDefaultConstructible determines whether a type has a public default - * constructor. - * - * struct S0 {}; // Implicit default constructor. - * struct S1 { S1(); }; - * struct S2 { explicit S2(int); }; // No implicit default constructor when - * // another one is present. - * struct S3 { S3() = delete; }; - * class C4 { C4(); }; // Default constructor is private. - * - * mozilla::IsDefaultConstructible::value is true; - * mozilla::IsDefaultConstructible::value is true; - * mozilla::IsDefaultConstructible::value is true; - * mozilla::IsDefaultConstructible::value is false; - * mozilla::IsDefaultConstructible::value is false; - * mozilla::IsDefaultConstructible::value is false. - */ -template -struct IsDefaultConstructible - : public detail::IsDefaultConstructibleImpl::Type {}; - -namespace detail { - struct DoIsDestructibleImpl { template ().~T())> static TrueType test(int); diff --git a/mfbt/tests/TestTypeTraits.cpp b/mfbt/tests/TestTypeTraits.cpp index 21d6a18eea145..5b618f6b816f7 100644 --- a/mfbt/tests/TestTypeTraits.cpp +++ b/mfbt/tests/TestTypeTraits.cpp @@ -18,7 +18,6 @@ using mozilla::DeclVal; using mozilla::IsArray; using mozilla::IsClass; using mozilla::IsConvertible; -using mozilla::IsDefaultConstructible; using mozilla::IsDestructible; using mozilla::IsFunction; using mozilla::IsPointer; @@ -209,104 +208,6 @@ static_assert(!IsSigned::value, static_assert(!IsUnsigned::value, "non-arithmetic types are not unsigned"); -struct TrivialCtor0 {}; -struct TrivialCtor1 { - int mX; -}; - -struct DefaultCtor0 { - DefaultCtor0() = default; -}; -struct DefaultCtor1 { - DefaultCtor1() = default; -}; -struct DefaultCtor2 { - DefaultCtor2() = default; - explicit DefaultCtor2(int) {} -}; - -struct NoDefaultCtor0 { - explicit NoDefaultCtor0(int) {} -}; -struct NoDefaultCtor1 { - NoDefaultCtor1() = delete; -}; - -class PrivateCtor0 { - PrivateCtor0() = default; -}; -class PrivateCtor1 { - PrivateCtor1() = default; -}; - -enum EnumCtor0 {}; -enum EnumCtor1 : int {}; - -enum class EnumClassCtor0 {}; -enum class EnumClassCtor1 : int {}; - -union UnionCtor0 {}; -union UnionCtor1 { - int mX; -}; - -union UnionCustomCtor0 { - explicit UnionCustomCtor0(int) {} -}; -union UnionCustomCtor1 { - int mX; - explicit UnionCustomCtor1(int aX) : mX(aX) {} -}; - -static_assert(IsDefaultConstructible::value, - "integral type is default-constructible"); - -static_assert(IsDefaultConstructible::value, - "trivial constructor class 0 is default-constructible"); -static_assert(IsDefaultConstructible::value, - "trivial constructor class 1 is default-constructible"); - -static_assert(IsDefaultConstructible::value, - "default constructor class 0 is default-constructible"); -static_assert(IsDefaultConstructible::value, - "default constructor class 1 is default-constructible"); -static_assert(IsDefaultConstructible::value, - "default constructor class 2 is default-constructible"); - -static_assert(!IsDefaultConstructible::value, - "no default constructor class is not default-constructible"); -static_assert(!IsDefaultConstructible::value, - "deleted default constructor class is not default-constructible"); - -static_assert( - !IsDefaultConstructible::value, - "private default constructor class 0 is not default-constructible"); -static_assert( - !IsDefaultConstructible::value, - "private default constructor class 1 is not default-constructible"); - -static_assert(IsDefaultConstructible::value, - "enum constructor 0 is default-constructible"); -static_assert(IsDefaultConstructible::value, - "enum constructor 1 is default-constructible"); - -static_assert(IsDefaultConstructible::value, - "enum class constructor 0 is default-constructible"); -static_assert(IsDefaultConstructible::value, - "enum class constructor 1 is default-constructible"); - -static_assert(IsDefaultConstructible::value, - "union constructor 0 is default-constructible"); -static_assert(IsDefaultConstructible::value, - "union constructor 1 is default-constructible"); - -static_assert( - !IsDefaultConstructible::value, - "union with custom 1-arg constructor 0 is not default-constructible"); -static_assert( - !IsDefaultConstructible::value, - "union with custom 1-arg constructor 1 is not default-constructible"); - class PublicDestructible { public: ~PublicDestructible();