Bug 1625138 - Part 5: Replace mozilla::IsDefaultConstructible with std::is_default_constructible. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D68359

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2020-03-28 13:57:12 +00:00
parent 1e4d8b891e
commit e7d63cc0a3
3 changed files with 2 additions and 139 deletions

View File

@ -272,8 +272,8 @@ struct SelectResultImpl {
? PackingStrategy::NullIsOk
: (detail::HasFreeLSB<V>::value && detail::HasFreeLSB<E>::value)
? PackingStrategy::LowBitTagIsError
: (IsDefaultConstructible<V>::value &&
IsDefaultConstructible<E>::value &&
: (std::is_default_constructible_v<V> &&
std::is_default_constructible_v<E> &&
IsPackableVariant<V, E>::value)
? PackingStrategy::PackedVariant
: PackingStrategy::Variant;

View File

@ -468,44 +468,6 @@ struct IsUnsigned : detail::IsUnsignedHelper<T> {};
namespace detail {
struct DoIsDefaultConstructibleImpl {
template <typename T, typename = decltype(T())>
static TrueType test(int);
template <typename T>
static FalseType test(...);
};
template <typename T>
struct IsDefaultConstructibleImpl : public DoIsDefaultConstructibleImpl {
typedef decltype(test<T>(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<int>::value is true;
* mozilla::IsDefaultConstructible<S0>::value is true;
* mozilla::IsDefaultConstructible<S1>::value is true;
* mozilla::IsDefaultConstructible<S2>::value is false;
* mozilla::IsDefaultConstructible<S3>::value is false;
* mozilla::IsDefaultConstructible<S4>::value is false.
*/
template <typename T>
struct IsDefaultConstructible
: public detail::IsDefaultConstructibleImpl<T>::Type {};
namespace detail {
struct DoIsDestructibleImpl {
template <typename T, typename = decltype(DeclVal<T&>().~T())>
static TrueType test(int);

View File

@ -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<NotIntConstructible>::value,
static_assert(!IsUnsigned<NotIntConstructible>::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<int>::value,
"integral type is default-constructible");
static_assert(IsDefaultConstructible<TrivialCtor0>::value,
"trivial constructor class 0 is default-constructible");
static_assert(IsDefaultConstructible<TrivialCtor1>::value,
"trivial constructor class 1 is default-constructible");
static_assert(IsDefaultConstructible<DefaultCtor0>::value,
"default constructor class 0 is default-constructible");
static_assert(IsDefaultConstructible<DefaultCtor1>::value,
"default constructor class 1 is default-constructible");
static_assert(IsDefaultConstructible<DefaultCtor2>::value,
"default constructor class 2 is default-constructible");
static_assert(!IsDefaultConstructible<NoDefaultCtor0>::value,
"no default constructor class is not default-constructible");
static_assert(!IsDefaultConstructible<NoDefaultCtor1>::value,
"deleted default constructor class is not default-constructible");
static_assert(
!IsDefaultConstructible<PrivateCtor0>::value,
"private default constructor class 0 is not default-constructible");
static_assert(
!IsDefaultConstructible<PrivateCtor1>::value,
"private default constructor class 1 is not default-constructible");
static_assert(IsDefaultConstructible<EnumCtor0>::value,
"enum constructor 0 is default-constructible");
static_assert(IsDefaultConstructible<EnumCtor1>::value,
"enum constructor 1 is default-constructible");
static_assert(IsDefaultConstructible<EnumClassCtor0>::value,
"enum class constructor 0 is default-constructible");
static_assert(IsDefaultConstructible<EnumClassCtor1>::value,
"enum class constructor 1 is default-constructible");
static_assert(IsDefaultConstructible<UnionCtor0>::value,
"union constructor 0 is default-constructible");
static_assert(IsDefaultConstructible<UnionCtor1>::value,
"union constructor 1 is default-constructible");
static_assert(
!IsDefaultConstructible<UnionCustomCtor0>::value,
"union with custom 1-arg constructor 0 is not default-constructible");
static_assert(
!IsDefaultConstructible<UnionCustomCtor1>::value,
"union with custom 1-arg constructor 1 is not default-constructible");
class PublicDestructible {
public:
~PublicDestructible();