зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625138 - Part 16: Replace mozilla::IsIntegral with std::is_integral. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68371 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1f5d157732
Коммит
ebec34a898
|
@ -7,6 +7,8 @@
|
|||
#ifndef TIME_UNITS_H
|
||||
#define TIME_UNITS_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "Intervals.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
@ -172,7 +174,7 @@ class TimeUnit final {
|
|||
TimeUnit operator*(T aVal) const {
|
||||
// See bug 853398 for the reason to block double multiplier.
|
||||
// If required, use MultDouble below and with caution.
|
||||
static_assert(mozilla::IsIntegral<T>::value, "Must be an integral type");
|
||||
static_assert(std::is_integral_v<T>, "Must be an integral type");
|
||||
return TimeUnit(mValue * aVal);
|
||||
}
|
||||
TimeUnit MultDouble(double aVal) const {
|
||||
|
|
|
@ -156,7 +156,7 @@ inline bool IsTimeValid(double aTime) {
|
|||
template <typename IntType, typename FloatType>
|
||||
IntType TruncateFloatToInt(FloatType f) {
|
||||
using std::numeric_limits;
|
||||
static_assert(mozilla::IsIntegral<IntType>::value == true,
|
||||
static_assert(std::is_integral_v<IntType> == true,
|
||||
"IntType must be an integral type");
|
||||
static_assert(std::is_floating_point_v<FloatType> == true,
|
||||
"FloatType must be a floating point type");
|
||||
|
|
|
@ -1774,7 +1774,7 @@ class PrincipalVerifier final : public Runnable {
|
|||
template <typename T, bool = std::is_unsigned_v<T>>
|
||||
struct IntChecker {
|
||||
static void Assert(T aInt) {
|
||||
static_assert(mozilla::IsIntegral<T>::value, "Not an integer!");
|
||||
static_assert(std::is_integral_v<T>, "Not an integer!");
|
||||
MOZ_ASSERT(aInt >= 0);
|
||||
}
|
||||
};
|
||||
|
@ -1782,7 +1782,7 @@ struct IntChecker {
|
|||
template <typename T>
|
||||
struct IntChecker<T, true> {
|
||||
static void Assert(T aInt) {
|
||||
static_assert(mozilla::IsIntegral<T>::value, "Not an integer!");
|
||||
static_assert(std::is_integral_v<T>, "Not an integer!");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ struct ParamTraits<nsTArray<E>> {
|
|||
// a data structure T for which IsPod<T>::value is true, yet also have a
|
||||
// ParamTraits<T> specialization.
|
||||
static const bool sUseWriteBytes =
|
||||
(mozilla::IsIntegral<E>::value || std::is_floating_point_v<E>);
|
||||
(std::is_integral_v<E> || std::is_floating_point_v<E>);
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
uint32_t length = aParam.Length();
|
||||
|
@ -648,7 +648,7 @@ struct ParamTraits<mozilla::Vector<E, N, AP>> {
|
|||
// a data structure T for which IsPod<T>::value is true, yet also have a
|
||||
// ParamTraits<T> specialization.
|
||||
static const bool sUseWriteBytes =
|
||||
(mozilla::IsIntegral<E>::value || std::is_floating_point_v<E>);
|
||||
(std::is_integral_v<E> || std::is_floating_point_v<E>);
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
uint32_t length = aParam.length();
|
||||
|
@ -729,7 +729,7 @@ struct ParamTraits<std::vector<E>> {
|
|||
// a data structure T for which IsPod<T>::value is true, yet also have a
|
||||
// ParamTraits<T> specialization.
|
||||
static const bool sUseWriteBytes =
|
||||
(mozilla::IsIntegral<E>::value || std::is_floating_point_v<E>);
|
||||
(std::is_integral_v<E> || std::is_floating_point_v<E>);
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
uint32_t length = aParam.size();
|
||||
|
|
|
@ -234,7 +234,7 @@ struct IPDLParamTraits<nsTArray<T>> {
|
|||
// a data structure T for which IsPod<T>::value is true, yet also have a
|
||||
// {IPDL,}ParamTraits<T> specialization.
|
||||
static const bool sUseWriteBytes =
|
||||
(mozilla::IsIntegral<T>::value || std::is_floating_point_v<T>);
|
||||
(std::is_integral_v<T> || std::is_floating_point_v<T>);
|
||||
};
|
||||
|
||||
// Maybe support for IPDLParamTraits
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef Utils_h
|
||||
#define Utils_h
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/TemplateLib.h"
|
||||
|
||||
|
@ -28,7 +30,7 @@ enum class Order {
|
|||
// Equal or Greater than the second integer.
|
||||
template <typename T>
|
||||
Order CompareInt(T aValue1, T aValue2) {
|
||||
static_assert(mozilla::IsIntegral<T>::value, "Type must be integral");
|
||||
static_assert(std::is_integral_v<T>, "Type must be integral");
|
||||
if (aValue1 < aValue2) {
|
||||
return Order::eLess;
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ class Atomic;
|
|||
template <typename T, MemoryOrdering Order>
|
||||
class Atomic<
|
||||
T, Order,
|
||||
typename EnableIf<IsIntegral<T>::value && !IsSame<T, bool>::value>::Type>
|
||||
typename EnableIf<std::is_integral_v<T> && !IsSame<T, bool>::value>::Type>
|
||||
: public detail::AtomicBaseIncDec<T, Order> {
|
||||
typedef typename detail::AtomicBaseIncDec<T, Order> Base;
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ struct BoundsCheckImpl<From, To, FromIsSigned, ToIsSigned> {
|
|||
|
||||
template <typename From, typename To,
|
||||
bool TypesAreIntegral =
|
||||
IsIntegral<From>::value&& IsIntegral<To>::value>
|
||||
std::is_integral_v<From>&& std::is_integral_v<To>>
|
||||
class BoundsChecker;
|
||||
|
||||
template <typename From>
|
||||
|
|
|
@ -178,7 +178,7 @@ inline HashNumber AddUintptrToHash<8>(HashNumber aHash, uintptr_t aValue) {
|
|||
* Currently, we support hashing uint32_t's, values which we can implicitly
|
||||
* convert to uint32_t, data pointers, and function pointers.
|
||||
*/
|
||||
template <typename T, bool TypeIsNotIntegral = !mozilla::IsIntegral<T>::value,
|
||||
template <typename T, bool TypeIsNotIntegral = !std::is_integral_v<T>,
|
||||
typename U = typename mozilla::EnableIf<TypeIsNotIntegral>::Type>
|
||||
MOZ_MUST_USE inline HashNumber AddToHash(HashNumber aHash, T aA) {
|
||||
/*
|
||||
|
@ -204,8 +204,8 @@ MOZ_MUST_USE inline HashNumber AddToHash(HashNumber aHash, A* aA) {
|
|||
// types are treated the same as 64-bit pointers, and smaller integral types are
|
||||
// first implicitly converted to 32 bits and then passed to AddUintptrToHash()
|
||||
// to be hashed.
|
||||
template <typename T, typename U = typename mozilla::EnableIf<
|
||||
mozilla::IsIntegral<T>::value>::Type>
|
||||
template <typename T,
|
||||
typename U = typename mozilla::EnableIf<std::is_integral_v<T>>::Type>
|
||||
MOZ_MUST_USE constexpr HashNumber AddToHash(HashNumber aHash, T aA) {
|
||||
return detail::AddUintptrToHash<sizeof(T)>(aHash, aA);
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ struct GeqZero<T, true> {
|
|||
|
||||
template <typename IntType>
|
||||
detail::IntegerRange<IntType> IntegerRange(IntType aEnd) {
|
||||
static_assert(IsIntegral<IntType>::value, "value must be integral");
|
||||
static_assert(std::is_integral_v<IntType>, "value must be integral");
|
||||
MOZ_ASSERT(detail::GeqZero<IntType>::isNonNegative(aEnd),
|
||||
"Should never have negative value here");
|
||||
return detail::IntegerRange<IntType>(aEnd);
|
||||
|
@ -163,7 +163,7 @@ detail::IntegerRange<IntType> IntegerRange(IntType aEnd) {
|
|||
|
||||
template <typename IntType1, typename IntType2>
|
||||
detail::IntegerRange<IntType2> IntegerRange(IntType1 aBegin, IntType2 aEnd) {
|
||||
static_assert(IsIntegral<IntType1>::value && IsIntegral<IntType2>::value,
|
||||
static_assert(std::is_integral_v<IntType1> && std::is_integral_v<IntType2>,
|
||||
"values must both be integral");
|
||||
static_assert(std::is_signed_v<IntType1> == std::is_signed_v<IntType2>,
|
||||
"signed/unsigned mismatch");
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include <stdint.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -76,7 +77,7 @@ struct SignedStdintTypeForSize
|
|||
|
||||
template <typename IntegerType>
|
||||
struct PositionOfSignBit {
|
||||
static_assert(IsIntegral<IntegerType>::value,
|
||||
static_assert(std::is_integral_v<IntegerType>,
|
||||
"PositionOfSignBit is only for integral types");
|
||||
// 8 here should be CHAR_BIT from limits.h, but the world has moved on.
|
||||
static const size_t value = 8 * sizeof(IntegerType) - 1;
|
||||
|
|
|
@ -489,7 +489,7 @@ constexpr bool IsPowerOfTwo(T x) {
|
|||
|
||||
template <typename T>
|
||||
inline T Clamp(const T aValue, const T aMin, const T aMax) {
|
||||
static_assert(IsIntegral<T>::value,
|
||||
static_assert(std::is_integral_v<T>,
|
||||
"Clamp accepts only integral types, so that it doesn't have"
|
||||
" to distinguish differently-signed zeroes (which users may"
|
||||
" or may not care to distinguish, likely at a perf cost) or"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef mozilla_Opaque_h
|
||||
#define mozilla_Opaque_h
|
||||
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace mozilla {
|
|||
*/
|
||||
template <typename T>
|
||||
class Opaque final {
|
||||
static_assert(mozilla::IsIntegral<T>::value,
|
||||
static_assert(std::is_integral_v<T>,
|
||||
"mozilla::Opaque only supports integral types");
|
||||
|
||||
T mValue;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define mozilla_Saturate_h
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
|
@ -41,7 +42,7 @@ class SaturateOp {
|
|||
// We should actually check for |std::is_scalar<T>::value| to be
|
||||
// true, but this type trait is not available everywhere. Relax
|
||||
// this assertion if you want to use floating point values as well.
|
||||
static_assert(IsIntegral<T>::value,
|
||||
static_assert(std::is_integral_v<T>,
|
||||
"Integral type required in instantiation");
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ class ThreadLocal : public Storage<T> {
|
|||
|
||||
template <typename T, template <typename U> class Storage>
|
||||
inline bool ThreadLocal<T, Storage>::init() {
|
||||
static_assert(std::is_pointer_v<T> || mozilla::IsIntegral<T>::value,
|
||||
static_assert(std::is_pointer_v<T> || std::is_integral_v<T>,
|
||||
"mozilla::ThreadLocal must be used with a pointer or "
|
||||
"integral type");
|
||||
static_assert(sizeof(T) <= sizeof(void*),
|
||||
|
|
|
@ -81,59 +81,6 @@ struct IsVoid : detail::IsVoidHelper<typename RemoveCV<T>::Type> {};
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct IsIntegralHelper : FalseType {};
|
||||
|
||||
template <>
|
||||
struct IsIntegralHelper<char> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<signed char> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<unsigned char> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<short> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<unsigned short> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<int> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<unsigned int> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<long> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<unsigned long> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<long long> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<unsigned long long> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<bool> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<wchar_t> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<char16_t> : TrueType {};
|
||||
template <>
|
||||
struct IsIntegralHelper<char32_t> : TrueType {};
|
||||
|
||||
} /* namespace detail */
|
||||
|
||||
/**
|
||||
* IsIntegral determines whether a type is an integral type.
|
||||
*
|
||||
* mozilla::IsIntegral<int>::value is true;
|
||||
* mozilla::IsIntegral<unsigned short>::value is true;
|
||||
* mozilla::IsIntegral<const long>::value is true;
|
||||
* mozilla::IsIntegral<int*>::value is false;
|
||||
* mozilla::IsIntegral<double>::value is false;
|
||||
*/
|
||||
template <typename T>
|
||||
struct IsIntegral : detail::IsIntegralHelper<typename RemoveCV<T>::Type> {};
|
||||
|
||||
template <typename T, typename U>
|
||||
struct IsSame;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct IsArrayHelper : FalseType {};
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdint.h>
|
||||
#include <algorithm> // for std::min, std::max
|
||||
#include <ostream>
|
||||
#include <type_traits>
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
@ -329,7 +330,7 @@ class TimeDurationValueCalculator {
|
|||
|
||||
template <typename T>
|
||||
static int64_t Multiply(int64_t aA, T aB) {
|
||||
static_assert(IsIntegral<T>::value,
|
||||
static_assert(std::is_integral_v<T>,
|
||||
"Using integer multiplication routine with non-integer type."
|
||||
" Further specialization required");
|
||||
return aA * static_cast<int64_t>(aB);
|
||||
|
|
|
@ -105,7 +105,7 @@ MFBT_API Result<LoadOrBranch, PCRelCheckError> CheckForPCRel(
|
|||
*/
|
||||
template <typename ResultT>
|
||||
inline ResultT SignExtend(const uint32_t aValue, const uint8_t aNumValidBits) {
|
||||
static_assert(IsIntegral<ResultT>::value && std::is_signed_v<ResultT>,
|
||||
static_assert(std::is_integral_v<ResultT> && std::is_signed_v<ResultT>,
|
||||
"ResultT must be a signed integral type");
|
||||
MOZ_ASSERT(aNumValidBits < 32U && aNumValidBits > 1);
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@ T RandomNumericLimit() {
|
|||
*/
|
||||
template <typename T>
|
||||
T RandomInteger() {
|
||||
static_assert(mozilla::IsIntegral<T>::value == true,
|
||||
"T must be an integral type");
|
||||
static_assert(std::is_integral_v<T> == true, "T must be an integral type");
|
||||
double r =
|
||||
static_cast<double>(FuzzingTraits::Random((sizeof(T) * CHAR_BIT) + 1));
|
||||
T x = static_cast<T>(pow(2.0, r)) - 1;
|
||||
|
@ -63,8 +62,7 @@ T RandomInteger() {
|
|||
*/
|
||||
template <typename T>
|
||||
T RandomIntegerRange(T min, T max) {
|
||||
static_assert(mozilla::IsIntegral<T>::value == true,
|
||||
"T must be an integral type");
|
||||
static_assert(std::is_integral_v<T> == true, "T must be an integral type");
|
||||
MOZ_ASSERT(min < max);
|
||||
std::uniform_int_distribution<T> d(min, max);
|
||||
return d(FuzzingTraits::Rng());
|
||||
|
|
|
@ -54,8 +54,7 @@ using namespace mozilla::fuzzing;
|
|||
*/
|
||||
template <typename T>
|
||||
void FuzzIntegralType(T* v, bool largeValues) {
|
||||
static_assert(mozilla::IsIntegral<T>::value == true,
|
||||
"T must be an integral type");
|
||||
static_assert(std::is_integral_v<T> == true, "T must be an integral type");
|
||||
switch (FuzzingTraits::Random(6)) {
|
||||
case 0:
|
||||
if (largeValues) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче