diff --git a/mfbt/TypeTraits.h b/mfbt/TypeTraits.h index e566a7ce6509..a205a0541206 100644 --- a/mfbt/TypeTraits.h +++ b/mfbt/TypeTraits.h @@ -99,6 +99,7 @@ template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; +template<> struct IsIntegralHelper : TrueType {}; } /* namespace detail */ @@ -440,6 +441,7 @@ template<> struct IsPod : TrueType {}; template<> struct IsPod : TrueType {}; template<> struct IsPod : TrueType {}; template<> struct IsPod : TrueType {}; +template<> struct IsPod : TrueType {}; template struct IsPod : TrueType {}; namespace detail { diff --git a/mfbt/tests/TestTypeTraits.cpp b/mfbt/tests/TestTypeTraits.cpp index 0ba953b74c3a..10bfd464887a 100644 --- a/mfbt/tests/TestTypeTraits.cpp +++ b/mfbt/tests/TestTypeTraits.cpp @@ -26,7 +26,9 @@ using mozilla::IsConvertible; using mozilla::IsDefaultConstructible; using mozilla::IsDestructible; using mozilla::IsEmpty; +using mozilla::IsIntegral; using mozilla::IsLvalueReference; +using mozilla::IsPod; using mozilla::IsPointer; using mozilla::IsReference; using mozilla::IsRvalueReference; @@ -52,6 +54,39 @@ static_assert(IsArray::value, static_assert(IsArray::value, "bool[5] is an array"); +static_assert(IsIntegral::value, + "char16_t is integral"); +static_assert(IsIntegral::value, + "char32_t is integral"); +static_assert(!IsIntegral::value, + "char& is not integral"); +static_assert(!IsIntegral::value, + "double is not integral"); + +static_assert(IsPod::value, + "bool is pod"); +static_assert(IsPod::value, + "char16_t is pod"); +static_assert(IsPod::value, + "char32_t is pod"); +struct YepItsAPod { int x; }; +static_assert(!IsPod::value, + "pod struct is pod"); +struct NopeItsNotAPod { + int x; + protected: + int y; +}; +static_assert(!IsPod::value, + "non-standard-layout struct is not pod"); +struct NopeStillNotAPod { + NopeStillNotAPod() : x(7) { } + int x; +}; +static_assert(!IsPod::value, + "struct with constructor is not pod"); + + static_assert(!IsPointer::value, "bool not a pointer"); static_assert(IsPointer::value,