зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625138 - Part 15: Replace mozilla::IsFloatingPoint with std::is_floating_point. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68370 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
13e9ad3137
Коммит
1f5d157732
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "MediaSegment.h"
|
||||
|
@ -157,7 +158,7 @@ IntType TruncateFloatToInt(FloatType f) {
|
|||
using std::numeric_limits;
|
||||
static_assert(mozilla::IsIntegral<IntType>::value == true,
|
||||
"IntType must be an integral type");
|
||||
static_assert(mozilla::IsFloatingPoint<FloatType>::value == true,
|
||||
static_assert(std::is_floating_point_v<FloatType> == true,
|
||||
"FloatType must be a floating point type");
|
||||
|
||||
if (mozilla::IsNaN(f)) {
|
||||
|
|
|
@ -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 || mozilla::IsFloatingPoint<E>::value);
|
||||
(mozilla::IsIntegral<E>::value || 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 || mozilla::IsFloatingPoint<E>::value);
|
||||
(mozilla::IsIntegral<E>::value || 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 || mozilla::IsFloatingPoint<E>::value);
|
||||
(mozilla::IsIntegral<E>::value || std::is_floating_point_v<E>);
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
uint32_t length = aParam.size();
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Variant.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
|
@ -232,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 || mozilla::IsFloatingPoint<T>::value);
|
||||
(mozilla::IsIntegral<T>::value || std::is_floating_point_v<T>);
|
||||
};
|
||||
|
||||
// Maybe support for IPDLParamTraits
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include "jsnum.h"
|
||||
|
||||
|
@ -129,9 +130,8 @@ inline uint64_t ConvertNumber<uint64_t, double>(double src) {
|
|||
template <typename To, typename From>
|
||||
inline To ConvertNumber(From src) {
|
||||
static_assert(
|
||||
!mozilla::IsFloatingPoint<From>::value ||
|
||||
(mozilla::IsFloatingPoint<From>::value &&
|
||||
mozilla::IsFloatingPoint<To>::value),
|
||||
!std::is_floating_point_v<From> ||
|
||||
(std::is_floating_point_v<From> && std::is_floating_point_v<To>),
|
||||
"conversion from floating point to int should have been handled by "
|
||||
"specializations above");
|
||||
return To(src);
|
||||
|
|
|
@ -416,6 +416,7 @@ MOZ_END_EXTERN_C
|
|||
|
||||
#ifdef __cplusplus
|
||||
# include "mozilla/TypeTraits.h"
|
||||
# include <type_traits>
|
||||
namespace mozilla {
|
||||
namespace detail {
|
||||
|
||||
|
@ -428,7 +429,7 @@ struct AssertionConditionType {
|
|||
static_assert(!IsFunction<ValueT>::value,
|
||||
"Expected boolean assertion condition, got a function! Did "
|
||||
"you intend to call that function?");
|
||||
static_assert(!IsFloatingPoint<ValueT>::value,
|
||||
static_assert(!std::is_floating_point_v<ValueT>,
|
||||
"It's often a bad idea to assert that a floating-point number "
|
||||
"is nonzero, because such assertions tend to intermittently "
|
||||
"fail. Shouldn't your code gracefully handle this case instead "
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -551,7 +552,7 @@ struct FuzzyEqualsEpsilon<double> {
|
|||
template <typename T>
|
||||
static MOZ_ALWAYS_INLINE bool FuzzyEqualsAdditive(
|
||||
T aValue1, T aValue2, T aEpsilon = detail::FuzzyEqualsEpsilon<T>::value()) {
|
||||
static_assert(IsFloatingPoint<T>::value, "floating point type required");
|
||||
static_assert(std::is_floating_point_v<T>, "floating point type required");
|
||||
return Abs(aValue1 - aValue2) <= aEpsilon;
|
||||
}
|
||||
|
||||
|
@ -570,7 +571,7 @@ static MOZ_ALWAYS_INLINE bool FuzzyEqualsAdditive(
|
|||
template <typename T>
|
||||
static MOZ_ALWAYS_INLINE bool FuzzyEqualsMultiplicative(
|
||||
T aValue1, T aValue2, T aEpsilon = detail::FuzzyEqualsEpsilon<T>::value()) {
|
||||
static_assert(IsFloatingPoint<T>::value, "floating point type required");
|
||||
static_assert(std::is_floating_point_v<T>, "floating point type required");
|
||||
// can't use std::min because of bug 965340
|
||||
T smaller = Abs(aValue1) < Abs(aValue2) ? Abs(aValue1) : Abs(aValue2);
|
||||
return Abs(aValue1 - aValue2) <= aEpsilon * smaller;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/Vector.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -35,7 +36,7 @@ class RollingMean {
|
|||
S mTotal;
|
||||
|
||||
public:
|
||||
static_assert(!IsFloatingPoint<T>::value,
|
||||
static_assert(!std::is_floating_point_v<T>,
|
||||
"floating-point types are unsupported due to rounding "
|
||||
"errors");
|
||||
|
||||
|
|
|
@ -134,29 +134,6 @@ struct IsSame;
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct IsFloatingPointHelper
|
||||
: IntegralConstant<bool, IsSame<T, float>::value ||
|
||||
IsSame<T, double>::value ||
|
||||
IsSame<T, long double>::value> {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* IsFloatingPoint determines whether a type is a floating point type (float,
|
||||
* double, long double).
|
||||
*
|
||||
* mozilla::IsFloatingPoint<int>::value is false;
|
||||
* mozilla::IsFloatingPoint<const float>::value is true;
|
||||
* mozilla::IsFloatingPoint<long double>::value is true;
|
||||
* mozilla::IsFloatingPoint<double*>::value is false.
|
||||
*/
|
||||
template <typename T>
|
||||
struct IsFloatingPoint
|
||||
: detail::IsFloatingPointHelper<typename RemoveCV<T>::Type> {};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct IsArrayHelper : FalseType {};
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ inline char RandomIntegerRange(char min, char max) {
|
|||
*/
|
||||
template <typename T>
|
||||
T RandomFloatingPointRange(T min, T max) {
|
||||
static_assert(mozilla::IsFloatingPoint<T>::value == true,
|
||||
static_assert(std::is_floating_point_v<T> == true,
|
||||
"T must be a floating point type");
|
||||
MOZ_ASSERT(min < max);
|
||||
std::uniform_real_distribution<T> d(
|
||||
|
@ -106,7 +106,7 @@ T RandomFloatingPointRange(T min, T max) {
|
|||
*/
|
||||
template <typename T>
|
||||
T RandomFloatingPoint() {
|
||||
static_assert(mozilla::IsFloatingPoint<T>::value == true,
|
||||
static_assert(std::is_floating_point_v<T> == true,
|
||||
"T must be a floating point type");
|
||||
int radix = RandomIntegerRange<int>(std::numeric_limits<T>::min_exponent,
|
||||
std::numeric_limits<T>::max_exponent);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <prinrval.h>
|
||||
#include <type_traits>
|
||||
#ifdef _WINDOWS
|
||||
# include <process.h>
|
||||
# define getpid _getpid
|
||||
|
@ -100,7 +101,7 @@ void FuzzIntegralType(T* v, bool largeValues) {
|
|||
*/
|
||||
template <typename T>
|
||||
void FuzzFloatingPointType(T* v, bool largeValues) {
|
||||
static_assert(mozilla::IsFloatingPoint<T>::value == true,
|
||||
static_assert(std::is_floating_point_v<T> == true,
|
||||
"T must be a floating point type");
|
||||
switch (FuzzingTraits::Random(6)) {
|
||||
case 0:
|
||||
|
|
Загрузка…
Ссылка в новой задаче