diff --git a/layout/style/CounterStyleManager.cpp b/layout/style/CounterStyleManager.cpp index 43ffeea7a377..d412ad64279a 100644 --- a/layout/style/CounterStyleManager.cpp +++ b/layout/style/CounterStyleManager.cpp @@ -6,6 +6,8 @@ #include "CounterStyleManager.h" +#include + #include "mozilla/ArenaObjectID.h" #include "mozilla/ArrayUtils.h" #include "mozilla/CheckedInt.h" @@ -287,7 +289,7 @@ static bool CJKIdeographicToText(CounterValue aOrdinal, nsAString& aResult, if (unitidx == 0) { unit10Kidx = pos / 4; } - auto cur = static_cast::Type>(aOrdinal) % 10; + auto cur = static_cast>(aOrdinal) % 10; if (cur == 0) { if (needZero) { needZero = false; diff --git a/mfbt/CheckedInt.h b/mfbt/CheckedInt.h index bb523e94dc7d..eba3d7877791 100644 --- a/mfbt/CheckedInt.h +++ b/mfbt/CheckedInt.h @@ -194,8 +194,7 @@ constexpr bool HasSignBit(T aX) { // Notice that signed-to-unsigned conversions are always well-defined in the // standard, as the value congruent modulo 2**n as expected. By contrast, // unsigned-to-signed is only well-defined if the value is representable. - return bool(typename MakeUnsigned::Type(aX) >> - PositionOfSignBit::value); + return bool(std::make_unsigned_t(aX) >> PositionOfSignBit::value); } // Bitwise ops may return a larger type, so it's good to use this inline @@ -282,9 +281,9 @@ constexpr bool IsAddValid(T aX, T aY) { // These bitwise operations can return a larger integer type, if T was a // small type like int8_t, so we explicitly cast to T. - typename MakeUnsigned::Type ux = aX; - typename MakeUnsigned::Type uy = aY; - typename MakeUnsigned::Type result = ux + uy; + std::make_unsigned_t ux = aX; + std::make_unsigned_t uy = aY; + std::make_unsigned_t result = ux + uy; return IsSigned::value ? HasSignBit(BinaryComplement(T((result ^ aX) & (result ^ aY)))) : BinaryComplement(aX) >= aY; @@ -300,9 +299,9 @@ constexpr bool IsSubValid(T aX, T aY) { // Subtraction is valid if either aX and aY have same sign, or aX-aY and aX // have same sign. Since the value of aX-aY is undefined if we have a signed // type, we compute it using the unsigned type of the same size. - typename MakeUnsigned::Type ux = aX; - typename MakeUnsigned::Type uy = aY; - typename MakeUnsigned::Type result = ux - uy; + std::make_unsigned_t ux = aX; + std::make_unsigned_t uy = aY; + std::make_unsigned_t result = ux - uy; return IsSigned::value ? HasSignBit(BinaryComplement(T((result ^ aX) & (aX ^ aY)))) diff --git a/mfbt/Latin1.h b/mfbt/Latin1.h index 24eb37b67659..f7593f77838b 100644 --- a/mfbt/Latin1.h +++ b/mfbt/Latin1.h @@ -12,6 +12,8 @@ #ifndef mozilla_Latin1_h #define mozilla_Latin1_h +#include + #include "mozilla/JsRust.h" #include "mozilla/Span.h" #include "mozilla/Tuple.h" @@ -32,7 +34,10 @@ namespace detail { constexpr size_t kShortStringLimitForInlinePaths = 16; template -class MakeUnsignedChar : public MakeUnsigned {}; +class MakeUnsignedChar { + public: + using Type = std::make_unsigned_t; +}; template <> class MakeUnsignedChar { diff --git a/mfbt/TypeTraits.h b/mfbt/TypeTraits.h index d66b10c4f50b..a2fa5df38b84 100644 --- a/mfbt/TypeTraits.h +++ b/mfbt/TypeTraits.h @@ -690,9 +690,6 @@ struct RemoveReference { typedef T Type; }; -template -struct Conditional; - namespace detail { enum Voidness { TIsVoid, TIsNotVoid }; @@ -730,95 +727,6 @@ struct AddRvalueReferenceHelper { template struct AddRvalueReference : detail::AddRvalueReferenceHelper {}; -/* 20.9.7.3 Sign modifications [meta.trans.sign] */ - -template -struct EnableIf; - -namespace detail { - -template -struct WithC : Conditional {}; - -template -struct WithV : Conditional {}; - -template -struct WithCV : WithC::Type> {}; - -template -struct CorrespondingUnsigned; - -template <> -struct CorrespondingUnsigned { - typedef unsigned char Type; -}; -template <> -struct CorrespondingUnsigned { - typedef unsigned char Type; -}; -template <> -struct CorrespondingUnsigned { - typedef unsigned short Type; -}; -template <> -struct CorrespondingUnsigned { - typedef unsigned int Type; -}; -template <> -struct CorrespondingUnsigned { - typedef unsigned long Type; -}; -template <> -struct CorrespondingUnsigned { - typedef unsigned long long Type; -}; - -template ::Type, - bool IsUnsignedIntegerType = - IsUnsigned::value && !IsSame::value> -struct MakeUnsigned; - -template -struct MakeUnsigned { - typedef T Type; -}; - -template -struct MakeUnsigned - : WithCV::value, IsVolatile::value, - typename CorrespondingUnsigned::Type> {}; - -} // namespace detail - -/** - * MakeUnsigned produces the corresponding unsigned integer type for a given - * integral type T, with the const/volatile qualifiers of T. T must be a - * possibly-const/volatile-qualified integral type that isn't bool. - * - * If T is already an unsigned integer type (not including char!), then T is - * produced. - * - * Otherwise, if T is an signed integer type, the unsigned variety of T, with - * T's const/volatile qualifiers, is produced. - * - * Otherwise, the unsigned integral type of the same size as T, with the lowest - * rank, with T's const/volatile qualifiers, is produced. (This basically only - * acts to produce unsigned char when T = char.) - * - * mozilla::MakeUnsigned::Type is unsigned long; - * mozilla::MakeUnsigned::Type is volatile unsigned int; - * mozilla::MakeUnsigned::Type is const unsigned short; - * mozilla::MakeUnsigned::Type is const unsigned char; - * mozilla::MakeUnsigned is an error; - * mozilla::MakeUnsigned is an error. - */ -template -struct MakeUnsigned - : EnableIf::value && - !IsSame::Type>::value, - typename detail::MakeUnsigned >::Type {}; - /* 20.9.7.4 Array modifications [meta.trans.arr] */ /** @@ -915,7 +823,7 @@ struct AddPointer { * ... * }; */ -template +template struct EnableIf {}; template diff --git a/mfbt/WrappingOperations.h b/mfbt/WrappingOperations.h index 9f2c92c46c22..4bbb2363cdc7 100644 --- a/mfbt/WrappingOperations.h +++ b/mfbt/WrappingOperations.h @@ -102,7 +102,7 @@ WrapToSigned(UnsignedType aValue) { namespace detail { template -constexpr T ToResult(typename MakeUnsigned::Type aUnsigned) { +constexpr T ToResult(std::make_unsigned_t aUnsigned) { // We could *always* return WrapToSigned and rely on unsigned conversion to // undo the wrapping when |T| is unsigned, but this seems clearer. return IsSigned::value ? WrapToSigned(aUnsigned) : aUnsigned; @@ -111,7 +111,7 @@ constexpr T ToResult(typename MakeUnsigned::Type aUnsigned) { template struct WrappingAddHelper { private: - using UnsignedT = typename MakeUnsigned::Type; + using UnsignedT = std::make_unsigned_t; public: MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW @@ -159,7 +159,7 @@ namespace detail { template struct WrappingSubtractHelper { private: - using UnsignedT = typename MakeUnsigned::Type; + using UnsignedT = std::make_unsigned_t; public: MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW @@ -205,7 +205,7 @@ namespace detail { template struct WrappingMultiplyHelper { private: - using UnsignedT = typename MakeUnsigned::Type; + using UnsignedT = std::make_unsigned_t; public: MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW diff --git a/mfbt/tests/TestCheckedInt.cpp b/mfbt/tests/TestCheckedInt.cpp index 80b13a207120..d69458864f4e 100644 --- a/mfbt/tests/TestCheckedInt.cpp +++ b/mfbt/tests/TestCheckedInt.cpp @@ -8,6 +8,7 @@ #include #include +#include using namespace mozilla; @@ -78,7 +79,7 @@ void test() { testTwiceBiggerType::run(); - typedef typename MakeUnsigned::Type unsignedT; + using unsignedT = std::make_unsigned_t; VERIFY(sizeof(unsignedT) == sizeof(T)); VERIFY(IsSigned::value == false); diff --git a/mfbt/tests/TestTypeTraits.cpp b/mfbt/tests/TestTypeTraits.cpp index 5784df4e3874..21d6a18eea14 100644 --- a/mfbt/tests/TestTypeTraits.cpp +++ b/mfbt/tests/TestTypeTraits.cpp @@ -25,7 +25,6 @@ using mozilla::IsPointer; using mozilla::IsSame; using mozilla::IsSigned; using mozilla::IsUnsigned; -using mozilla::MakeUnsigned; using mozilla::RemoveExtent; using mozilla::RemovePointer; @@ -401,40 +400,6 @@ static_assert( "decltype should work using a DeclVal'd struct without a default " "constructor"); -static_assert( - IsSame::Type, const unsigned char>::value, - "const signed char won't unsignify correctly"); -static_assert(IsSame::Type, - volatile unsigned short>::value, - "volatile signed short won't unsignify correctly"); -static_assert(IsSame::Type, - const volatile unsigned int>::value, - "const volatile signed int won't unsignify correctly"); -static_assert(IsSame::Type, unsigned long>::value, - "signed long won't unsignify correctly"); - -static_assert( - IsSame::Type, const unsigned char>::value, - "const unsigned char won't unsignify correctly"); - -static_assert(IsSame::Type, - volatile unsigned short>::value, - "volatile unsigned short won't unsignify correctly"); -static_assert(IsSame::Type, - const volatile unsigned int>::value, - "const volatile unsigned int won't unsignify correctly"); -static_assert(IsSame::Type, unsigned long>::value, - "signed long won't unsignify correctly"); - -static_assert(IsSame::Type, unsigned char>::value, - "char won't unsignify correctly"); -static_assert( - IsSame::Type, volatile unsigned char>::value, - "volatile char won't unsignify correctly"); -static_assert( - IsSame::Type, const unsigned char>::value, - "const char won't unsignify correctly"); - static_assert(IsSame::Type, int>::value, "removing extent from non-array must return the non-array"); static_assert( diff --git a/mozglue/misc/interceptor/Arm64.h b/mozglue/misc/interceptor/Arm64.h index 6b0f949ac524..6557f1bc49cd 100644 --- a/mozglue/misc/interceptor/Arm64.h +++ b/mozglue/misc/interceptor/Arm64.h @@ -7,6 +7,8 @@ #ifndef mozilla_interceptor_Arm64_h #define mozilla_interceptor_Arm64_h +#include + #include "mozilla/Assertions.h" #include "mozilla/CheckedInt.h" #include "mozilla/MathAlgorithms.h" @@ -107,8 +109,7 @@ inline ResultT SignExtend(const uint32_t aValue, const uint8_t aNumValidBits) { "ResultT must be a signed integral type"); MOZ_ASSERT(aNumValidBits < 32U && aNumValidBits > 1); - using UnsignedResultT = - typename Decay::Type>::Type; + using UnsignedResultT = typename Decay>::Type; const uint8_t kResultWidthBits = sizeof(ResultT) * 8; diff --git a/xpcom/ds/PerfectHash.h b/xpcom/ds/PerfectHash.h index cc4198193c77..1e7585546288 100644 --- a/xpcom/ds/PerfectHash.h +++ b/xpcom/ds/PerfectHash.h @@ -9,7 +9,7 @@ #ifndef mozilla_PerfectHash_h #define mozilla_PerfectHash_h -#include "mozilla/TypeTraits.h" +#include namespace mozilla { namespace perfecthash { @@ -25,8 +25,8 @@ constexpr uint32_t FNV_PRIME = 16777619; template inline uint32_t Hash(uint32_t aBasis, const C* aKey, size_t aLen) { for (size_t i = 0; i < aLen; ++i) { - aBasis = (aBasis ^ static_cast::Type>(aKey[i])) * - FNV_PRIME; + aBasis = + (aBasis ^ static_cast>(aKey[i])) * FNV_PRIME; } return aBasis; } @@ -47,4 +47,4 @@ inline const Entry& Lookup(const C* aKey, size_t aLen, } // namespace perfecthash } // namespace mozilla -#endif // !defined(mozilla_PerfectHash_h) \ No newline at end of file +#endif // !defined(mozilla_PerfectHash_h)