зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625138 - Part 33: Replace mozilla::IntegralConstant with std::integral_constant. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68552 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
32cb16fc45
Коммит
9de017ffb8
|
@ -2830,7 +2830,8 @@ struct CreateGlobalOptionsWithXPConnect {
|
|||
|
||||
template <class T>
|
||||
using IsGlobalWithXPConnect =
|
||||
IntegralConstant<bool, std::is_base_of<nsGlobalWindowInner, T>::value ||
|
||||
std::integral_constant<bool,
|
||||
std::is_base_of<nsGlobalWindowInner, T>::value ||
|
||||
std::is_base_of<MessageManagerGlobal, T>::value>;
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -115,8 +115,8 @@ struct RemoveCVR {
|
|||
|
||||
template <typename T>
|
||||
struct IsTriviallySerializable
|
||||
: public IntegralConstant<bool, std::is_enum<T>::value ||
|
||||
std::is_arithmetic<T>::value> {};
|
||||
: public std::integral_constant<bool, std::is_enum<T>::value ||
|
||||
std::is_arithmetic<T>::value> {};
|
||||
|
||||
struct ProducerConsumerQueue;
|
||||
class Producer;
|
||||
|
|
|
@ -928,7 +928,7 @@ class HashMapEntry {
|
|||
|
||||
template <typename K, typename V>
|
||||
struct IsPod<HashMapEntry<K, V>>
|
||||
: IntegralConstant<bool, IsPod<K>::value && IsPod<V>::value> {};
|
||||
: std::integral_constant<bool, IsPod<K>::value && IsPod<V>::value> {};
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
|
17
mfbt/Span.h
17
mfbt/Span.h
|
@ -92,13 +92,13 @@ struct is_std_array : public is_std_array_oracle<std::remove_cv_t<T>> {};
|
|||
|
||||
template <size_t From, size_t To>
|
||||
struct is_allowed_extent_conversion
|
||||
: public mozilla::IntegralConstant<
|
||||
bool, From == To || From == mozilla::dynamic_extent ||
|
||||
To == mozilla::dynamic_extent> {};
|
||||
: public std::integral_constant<bool, From == To ||
|
||||
From == mozilla::dynamic_extent ||
|
||||
To == mozilla::dynamic_extent> {};
|
||||
|
||||
template <class From, class To>
|
||||
struct is_allowed_element_type_conversion
|
||||
: public mozilla::IntegralConstant<
|
||||
: public std::integral_constant<
|
||||
bool, std::is_convertible_v<From (*)[], To (*)[]>> {};
|
||||
|
||||
template <class Span, bool IsConst>
|
||||
|
@ -766,13 +766,14 @@ namespace span_details {
|
|||
// see it as constexpr and so will fail compilation of the template
|
||||
template <class ElementType, size_t Extent>
|
||||
struct calculate_byte_size
|
||||
: mozilla::IntegralConstant<size_t, static_cast<size_t>(
|
||||
sizeof(ElementType) *
|
||||
static_cast<size_t>(Extent))> {};
|
||||
: std::integral_constant<size_t,
|
||||
static_cast<size_t>(sizeof(ElementType) *
|
||||
static_cast<size_t>(Extent))> {
|
||||
};
|
||||
|
||||
template <class ElementType>
|
||||
struct calculate_byte_size<ElementType, dynamic_extent>
|
||||
: mozilla::IntegralConstant<size_t, dynamic_extent> {};
|
||||
: std::integral_constant<size_t, dynamic_extent> {};
|
||||
} // namespace span_details
|
||||
|
||||
// [Span.objectrep], views of object representation
|
||||
|
|
|
@ -54,7 +54,7 @@ struct CheckConvertibilityImpl<Source, Target, false> : FalseType {};
|
|||
template <typename... SourceTypes, typename... TargetTypes>
|
||||
struct CheckConvertibilityImpl<Group<SourceTypes...>, Group<TargetTypes...>,
|
||||
true>
|
||||
: IntegralConstant<
|
||||
: std::integral_constant<
|
||||
bool,
|
||||
tl::And<std::is_convertible_v<SourceTypes, TargetTypes>...>::value> {
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
/*
|
||||
|
@ -23,20 +24,9 @@ namespace mozilla {
|
|||
|
||||
/* 20.9.3 Helper classes [meta.help] */
|
||||
|
||||
/**
|
||||
* Helper class used as a base for various type traits, exposed publicly
|
||||
* because <type_traits> exposes it as well.
|
||||
*/
|
||||
template <typename T, T Value>
|
||||
struct IntegralConstant {
|
||||
static constexpr T value = Value;
|
||||
typedef T ValueType;
|
||||
typedef IntegralConstant<T, Value> Type;
|
||||
};
|
||||
|
||||
/** Convenient aliases. */
|
||||
typedef IntegralConstant<bool, true> TrueType;
|
||||
typedef IntegralConstant<bool, false> FalseType;
|
||||
typedef std::integral_constant<bool, true> TrueType;
|
||||
typedef std::integral_constant<bool, false> FalseType;
|
||||
|
||||
/* 20.9.4 Unary type traits [meta.unary] */
|
||||
|
||||
|
@ -46,7 +36,7 @@ typedef IntegralConstant<bool, false> FalseType;
|
|||
* Traits class for identifying POD types. Until C++11 there's no automatic
|
||||
* way to detect PODs, so for the moment this is done manually. Users may
|
||||
* define specializations of this class that inherit from mozilla::TrueType and
|
||||
* mozilla::FalseType (or equivalently mozilla::IntegralConstant<bool, true or
|
||||
* mozilla::FalseType (or equivalently std::integral_constant<bool, true or
|
||||
* false>, or conveniently from mozilla::IsPod for composite types) as needed to
|
||||
* ensure correct IsPod behavior.
|
||||
*/
|
||||
|
|
|
@ -40,8 +40,8 @@ struct HasPointerTypeHelper {
|
|||
|
||||
template <class T>
|
||||
class HasPointerType
|
||||
: public IntegralConstant<bool,
|
||||
sizeof(HasPointerTypeHelper::Test<T>(0)) == 1> {};
|
||||
: public std::integral_constant<bool, sizeof(HasPointerTypeHelper::Test<T>(
|
||||
0)) == 1> {};
|
||||
|
||||
template <class T, class D, bool = HasPointerType<D>::value>
|
||||
struct PointerTypeImpl {
|
||||
|
|
|
@ -118,7 +118,7 @@ def main(output, *filenames):
|
|||
print("\ntemplate<class T> struct CategoricalLabelId {};", file=output)
|
||||
for name, _, id in enums:
|
||||
print("template<> struct CategoricalLabelId<%s> : "
|
||||
"IntegralConstant<uint32_t, %s> {};" % (name, id), file=output)
|
||||
"std::integral_constant<uint32_t, %s> {};" % (name, id), file=output)
|
||||
|
||||
# Footer.
|
||||
print(footer, file=output)
|
||||
|
|
|
@ -81,7 +81,7 @@ struct MethodTrait : MethodTraitsHelper<std::remove_reference_t<T>> {};
|
|||
|
||||
template <typename MethodType>
|
||||
using TakesArgument =
|
||||
IntegralConstant<bool, detail::MethodTrait<MethodType>::ArgSize != 0>;
|
||||
std::integral_constant<bool, detail::MethodTrait<MethodType>::ArgSize != 0>;
|
||||
|
||||
template <typename MethodType, typename TargetType>
|
||||
using ReturnTypeIs =
|
||||
|
@ -562,8 +562,9 @@ class MozPromise : public MozPromiseBase {
|
|||
typename detail::MethodTrait<ResolveMethodType>::ReturnType>::Type;
|
||||
using R2 = typename RemoveSmartPointer<
|
||||
typename detail::MethodTrait<RejectMethodType>::ReturnType>::Type;
|
||||
using SupportChaining = IntegralConstant<bool, IsMozPromise<R1>::value &&
|
||||
IsSame<R1, R2>::value>;
|
||||
using SupportChaining =
|
||||
std::integral_constant<bool, IsMozPromise<R1>::value &&
|
||||
IsSame<R1, R2>::value>;
|
||||
|
||||
// Fall back to MozPromise when promise chaining is not supported to make
|
||||
// code compile.
|
||||
|
@ -626,7 +627,8 @@ class MozPromise : public MozPromiseBase {
|
|||
|
||||
using R1 = typename RemoveSmartPointer<typename detail::MethodTrait<
|
||||
ResolveRejectMethodType>::ReturnType>::Type;
|
||||
using SupportChaining = IntegralConstant<bool, IsMozPromise<R1>::value>;
|
||||
using SupportChaining =
|
||||
std::integral_constant<bool, IsMozPromise<R1>::value>;
|
||||
|
||||
// Fall back to MozPromise when promise chaining is not supported to make
|
||||
// code compile.
|
||||
|
@ -685,8 +687,9 @@ class MozPromise : public MozPromiseBase {
|
|||
typename detail::MethodTrait<ResolveFunction>::ReturnType>::Type;
|
||||
using R2 = typename RemoveSmartPointer<
|
||||
typename detail::MethodTrait<RejectFunction>::ReturnType>::Type;
|
||||
using SupportChaining = IntegralConstant<bool, IsMozPromise<R1>::value &&
|
||||
IsSame<R1, R2>::value>;
|
||||
using SupportChaining =
|
||||
std::integral_constant<bool, IsMozPromise<R1>::value &&
|
||||
IsSame<R1, R2>::value>;
|
||||
|
||||
// Fall back to MozPromise when promise chaining is not supported to make
|
||||
// code compile.
|
||||
|
@ -756,7 +759,8 @@ class MozPromise : public MozPromiseBase {
|
|||
|
||||
using R1 = typename RemoveSmartPointer<
|
||||
typename detail::MethodTrait<ResolveRejectFunction>::ReturnType>::Type;
|
||||
using SupportChaining = IntegralConstant<bool, IsMozPromise<R1>::value>;
|
||||
using SupportChaining =
|
||||
std::integral_constant<bool, IsMozPromise<R1>::value>;
|
||||
|
||||
// Fall back to MozPromise when promise chaining is not supported to make
|
||||
// code compile.
|
||||
|
|
Загрузка…
Ссылка в новой задаче