Bug 1628751 - Replace use of standard library traits classes by the _v or _t versions r=jwalden

Differential Revision: https://phabricator.services.mozilla.com/D70405

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jon Coppeard 2020-04-14 09:05:55 +00:00
parent fe6e67d2dd
commit a9cd50a889
41 changed files with 121 additions and 132 deletions

View File

@ -316,9 +316,9 @@ struct JSPropertySpec {
}
};
#define JS_CHECK_ACCESSOR_FLAGS(flags) \
(static_cast<std::enable_if<((flags) & ~(JSPROP_ENUMERATE | \
JSPROP_PERMANENT)) == 0>::type>(0), \
#define JS_CHECK_ACCESSOR_FLAGS(flags) \
(static_cast<std::enable_if_t<((flags) & ~(JSPROP_ENUMERATE | \
JSPROP_PERMANENT)) == 0>>(0), \
(flags))
#define JS_PSG(name, getter, flags) \

View File

@ -54,7 +54,7 @@
#include <stddef.h> // size_t
#include <stdint.h> // UINT32_MAX
#include <type_traits> // std::conditional, std::is_same
#include <type_traits> // std::conditional_t, std::is_same_v
#include "js/UniquePtr.h" // js::UniquePtr
#include "js/Utility.h" // JS::FreePolicy
@ -75,8 +75,8 @@ enum class SourceOwnership {
template <typename Unit>
class SourceText final {
private:
static_assert(std::is_same<Unit, mozilla::Utf8Unit>::value ||
std::is_same<Unit, char16_t>::value,
static_assert(std::is_same_v<Unit, mozilla::Utf8Unit> ||
std::is_same_v<Unit, char16_t>,
"Unit must be either char16_t or Utf8Unit for "
"SourceText<Unit>");
@ -95,8 +95,8 @@ class SourceText final {
public:
// A C++ character type that can represent the source units -- suitable for
// passing to C++ string functions.
using CharT = typename std::conditional<std::is_same<Unit, char16_t>::value,
char16_t, char>::type;
using CharT =
std::conditional_t<std::is_same_v<Unit, char16_t>, char16_t, char>;
public:
/**
@ -179,9 +179,9 @@ class SourceText final {
* UTF-16 case this overload and the one above would be identical. So we
* use SFINAE to expose the |CharT| overload only if it's different.)
*/
template <typename Char, typename = typename std::enable_if<
std::is_same<Char, CharT>::value &&
!std::is_same<Char, Unit>::value>::type>
template <typename Char,
typename = std::enable_if_t<std::is_same_v<Char, CharT> &&
!std::is_same_v<Char, Unit>>>
MOZ_IS_CLASS_INIT MOZ_MUST_USE bool init(JSContext* cx, const Char* chars,
size_t charsLength,
SourceOwnership ownership) {
@ -207,9 +207,9 @@ class SourceText final {
* then in the UTF-16 case this overload and the one above would be identical.
* So we use SFINAE to expose the |CharT| overload only if it's different.)
*/
template <typename Char, typename = typename std::enable_if<
std::is_same<Char, CharT>::value &&
!std::is_same<Char, Unit>::value>::type>
template <typename Char,
typename = std::enable_if_t<std::is_same_v<Char, CharT> &&
!std::is_same_v<Char, Unit>>>
MOZ_MUST_USE bool init(JSContext* cx,
js::UniquePtr<Char[], JS::FreePolicy> data,
size_t dataLength) {

View File

@ -326,7 +326,7 @@ class StackFrame {
template <typename T>
void construct(T* ptr) {
static_assert(std::is_base_of<BaseStackFrame, ConcreteStackFrame<T>>::value,
static_assert(std::is_base_of_v<BaseStackFrame, ConcreteStackFrame<T>>,
"ConcreteStackFrame<T> must inherit from BaseStackFrame");
static_assert(
sizeof(ConcreteStackFrame<T>) == sizeof(*base()),
@ -714,7 +714,7 @@ class Node {
static_assert(
sizeof(Concrete<T>) == sizeof(*base()),
"ubi::Base specializations must be the same size as ubi::Base");
static_assert(std::is_base_of<Base, Concrete<T>>::value,
static_assert(std::is_base_of_v<Base, Concrete<T>>,
"ubi::Concrete<T> must inherit from ubi::Base");
Concrete<T>::construct(base(), ptr);
}

View File

@ -421,11 +421,11 @@ bool DataViewObject::read(JSContext* cx, Handle<DataViewObject*> obj,
template <typename T>
static inline T WrappingConvert(int32_t value) {
if (std::is_unsigned<T>::value) {
if (std::is_unsigned_v<T>) {
return static_cast<T>(value);
}
return WrapToSigned(static_cast<typename std::make_unsigned<T>::type>(value));
return WrapToSigned(static_cast<typename std::make_unsigned_t<T>>(value));
}
template <typename NativeType>

View File

@ -960,7 +960,7 @@ static JSString* FormattedNumberToString(
JSContext* cx, PartitionNumberPatternResult formattedValue) {
#ifndef U_HIDE_DRAFT_API
static_assert(
std::is_same<PartitionNumberPatternResult, const UFormattedValue*>::value,
std::is_same_v<PartitionNumberPatternResult, const UFormattedValue*>,
"UFormattedValue arm");
UErrorCode status = U_ZERO_ERROR;
@ -973,9 +973,9 @@ static JSString* FormattedNumberToString(
return NewStringCopyN<CanGC>(cx, str, AssertedCast<uint32_t>(strLength));
#else
static_assert(std::is_same<PartitionNumberPatternResult,
const UFormattedNumber*>::value,
"UFormattedNumber arm");
static_assert(
std::is_same_v<PartitionNumberPatternResult, const UFormattedNumber*>,
"UFormattedNumber arm");
return CallICU(cx,
[formatted](UChar* chars, int32_t size, UErrorCode* status) {

View File

@ -2429,7 +2429,7 @@ static_assert(sizeof(PRFuncPtr) == sizeof(void*));
static_assert(numeric_limits<double>::is_signed);
template <typename TargetType, typename FromType,
bool FromIsIntegral = std::is_integral<FromType>::value>
bool FromIsIntegral = std::is_integral_v<FromType>>
struct ConvertImpl;
template <typename TargetType, typename FromType>
@ -2441,10 +2441,8 @@ struct ConvertImpl<TargetType, FromType, false> {
template <typename TargetType>
struct ConvertUnsignedTargetTo {
static TargetType convert(
typename std::make_unsigned<TargetType>::type input) {
return std::is_signed<TargetType>::value ? mozilla::WrapToSigned(input)
: input;
static TargetType convert(std::make_unsigned_t<TargetType> input) {
return std::is_signed_v<TargetType> ? mozilla::WrapToSigned(input) : input;
}
};
@ -2459,7 +2457,7 @@ struct ConvertUnsignedTargetTo<char16_t> {
template <typename TargetType, typename FromType>
struct ConvertImpl<TargetType, FromType, true> {
static MOZ_ALWAYS_INLINE TargetType Convert(FromType input) {
using UnsignedTargetType = typename std::make_unsigned<TargetType>::type;
using UnsignedTargetType = std::make_unsigned_t<TargetType>;
auto resultUnsigned = static_cast<UnsignedTargetType>(input);
return ConvertUnsignedTargetTo<TargetType>::convert(resultUnsigned);
@ -2468,9 +2466,9 @@ struct ConvertImpl<TargetType, FromType, true> {
template <class TargetType, class FromType>
static MOZ_ALWAYS_INLINE TargetType Convert(FromType d) {
static_assert(std::is_integral<FromType>::value !=
std::is_floating_point<FromType>::value,
"should only be converting from floating/integral type");
static_assert(
std::is_integral_v<FromType> != std::is_floating_point_v<FromType>,
"should only be converting from floating/integral type");
return ConvertImpl<TargetType, FromType>::Convert(d);
}

View File

@ -102,7 +102,7 @@ class AbstractScopePtr {
// or otherwise would reify to a particular scope type.
template <typename T>
bool is() const {
static_assert(std::is_base_of<Scope, T>::value,
static_assert(std::is_base_of_v<Scope, T>,
"Trying to ask about non-Scope type");
if (isNullptr()) {
return false;

View File

@ -803,9 +803,8 @@ inline typename BinASTParserPerTokenizer<Tok>::FinalParser*
BinASTParserPerTokenizer<Tok>::asFinalParser() {
// Same as GeneralParser::asFinalParser, verify the inheritance to
// make sure the static downcast works.
static_assert(
std::is_base_of<BinASTParserPerTokenizer<Tok>, FinalParser>::value,
"inheritance relationship required by the static_cast<> below");
static_assert(std::is_base_of_v<BinASTParserPerTokenizer<Tok>, FinalParser>,
"inheritance relationship required by the static_cast<> below");
return static_cast<FinalParser*>(this);
}
@ -813,9 +812,8 @@ BinASTParserPerTokenizer<Tok>::asFinalParser() {
template <typename Tok>
inline const typename BinASTParserPerTokenizer<Tok>::FinalParser*
BinASTParserPerTokenizer<Tok>::asFinalParser() const {
static_assert(
std::is_base_of<BinASTParserPerTokenizer<Tok>, FinalParser>::value,
"inheritance relationship required by the static_cast<> below");
static_assert(std::is_base_of_v<BinASTParserPerTokenizer<Tok>, FinalParser>,
"inheritance relationship required by the static_cast<> below");
return static_cast<const FinalParser*>(this);
}

View File

@ -110,7 +110,7 @@ template <class ParseHandler, typename Unit>
inline typename GeneralParser<ParseHandler, Unit>::FinalParser*
GeneralParser<ParseHandler, Unit>::asFinalParser() {
static_assert(
std::is_base_of<GeneralParser<ParseHandler, Unit>, FinalParser>::value,
std::is_base_of_v<GeneralParser<ParseHandler, Unit>, FinalParser>,
"inheritance relationship required by the static_cast<> below");
return static_cast<FinalParser*>(this);
@ -120,7 +120,7 @@ template <class ParseHandler, typename Unit>
inline const typename GeneralParser<ParseHandler, Unit>::FinalParser*
GeneralParser<ParseHandler, Unit>::asFinalParser() const {
static_assert(
std::is_base_of<GeneralParser<ParseHandler, Unit>, FinalParser>::value,
std::is_base_of_v<GeneralParser<ParseHandler, Unit>, FinalParser>,
"inheritance relationship required by the static_cast<> below");
return static_cast<const FinalParser*>(this);

View File

@ -1784,9 +1784,8 @@ ParserAnyCharsAccess<Parser>::anyChars(const GeneralTokenStreamChars* ts) {
// then translate that to the enclosing Parser*, then return the |anyChars|
// member within.
static_assert(
std::is_base_of<GeneralTokenStreamChars, TokenStreamSpecific>::value,
"the static_cast<> below assumes a base-class relationship");
static_assert(std::is_base_of_v<GeneralTokenStreamChars, TokenStreamSpecific>,
"the static_cast<> below assumes a base-class relationship");
const auto* tss = static_cast<const TokenStreamSpecific*>(ts);
auto tssAddr = reinterpret_cast<uintptr_t>(tss);

View File

@ -1738,14 +1738,13 @@ bool TokenStreamCharsBase<Unit>::addLineOfContext(ErrorMetadata* err,
// always the case for Unit=char16_t), the UTF-16 offsets are exactly the
// encoded offsets. Otherwise we must convert offset/length from UTF-8 to
// UTF-16.
if (std::is_same<Unit, char16_t>::value) {
if constexpr (std::is_same_v<Unit, char16_t>) {
MOZ_ASSERT(utf16WindowLength == encodedWindowLength,
"UTF-16 to UTF-16 shouldn't change window length");
err->tokenOffset = encodedTokenOffset;
err->lineLength = encodedWindowLength;
} else {
MOZ_ASSERT((std::is_same<Unit, Utf8Unit>::value),
"should only see UTF-8 here");
static_assert(std::is_same_v<Unit, Utf8Unit>, "should only see UTF-8 here");
bool simple = utf16WindowLength == encodedWindowLength;
#ifdef DEBUG

View File

@ -1923,7 +1923,7 @@ class GeneralTokenStreamChars : public SpecializedTokenStreamCharsBase<Unit> {
TokenStreamSpecific* asSpecific() {
static_assert(
std::is_base_of<GeneralTokenStreamChars, TokenStreamSpecific>::value,
std::is_base_of_v<GeneralTokenStreamChars, TokenStreamSpecific>,
"static_cast below presumes an inheritance relationship");
return static_cast<TokenStreamSpecific*>(this);

View File

@ -788,7 +788,7 @@ Statistics::Statistics(GCRuntime* gc)
#ifdef DEBUG
for (const auto& duration : totalTimes_) {
using ElementType = std::remove_reference_t<decltype(duration)>;
static_assert(!std::is_trivially_constructible<ElementType>::value,
static_assert(!std::is_trivially_constructible_v<ElementType>,
"Statistics::Statistics will only initialize "
"totalTimes_'s elements if their default constructor is "
"non-trivial");

View File

@ -1567,8 +1567,8 @@ bool CacheIRCompiler::emitGuardToInt32() {
// To select this function simply omit the |Label* fail| parameter for the
// emitter lambda function.
template <typename EmitDouble>
static typename std::enable_if_t<
mozilla::FunctionTypeTraits<EmitDouble>::arity == 1, void>
static std::enable_if_t<mozilla::FunctionTypeTraits<EmitDouble>::arity == 1,
void>
EmitGuardDouble(CacheIRCompiler* compiler, MacroAssembler& masm,
ValueOperand input, FailurePath* failure,
EmitDouble emitDouble) {
@ -1579,8 +1579,8 @@ EmitGuardDouble(CacheIRCompiler* compiler, MacroAssembler& masm,
}
template <typename EmitDouble>
static typename std::enable_if_t<
mozilla::FunctionTypeTraits<EmitDouble>::arity == 2, void>
static std::enable_if_t<mozilla::FunctionTypeTraits<EmitDouble>::arity == 2,
void>
EmitGuardDouble(CacheIRCompiler* compiler, MacroAssembler& masm,
ValueOperand input, FailurePath* failure,
EmitDouble emitDouble) {
@ -4433,7 +4433,7 @@ bool CacheIRCompiler::emitCompareBigIntInt32ResultShared(
JSOp op, const AutoOutputRegister& output) {
MOZ_ASSERT(IsLooseEqualityOp(op) || IsRelationalOp(op));
static_assert(std::is_same<BigInt::Digit, uintptr_t>::value,
static_assert(std::is_same_v<BigInt::Digit, uintptr_t>,
"BigInt digit can be loaded in a pointer-sized register");
static_assert(sizeof(BigInt::Digit) >= sizeof(uint32_t),
"BigInt digit stores at least an uint32");
@ -5815,7 +5815,7 @@ struct VMFunctionReturnType<R (*)(JSContext*, Args...)> {
// By convention VMFunctions returning `bool` use an output parameter.
using ReturnType =
std::conditional_t<std::is_same<R, bool>::value, LastArgument, R>;
std::conditional_t<std::is_same_v<R, bool>, LastArgument, R>;
};
template <class>

View File

@ -9658,8 +9658,8 @@ void CodeGenerator::visitStoreElementV(LStoreElementV* lir) {
template <typename T>
void CodeGenerator::emitStoreElementHoleT(T* lir) {
static_assert(std::is_same<T, LStoreElementHoleT>::value ||
std::is_same<T, LFallibleStoreElementT>::value,
static_assert(std::is_same_v<T, LStoreElementHoleT> ||
std::is_same_v<T, LFallibleStoreElementT>,
"emitStoreElementHoleT called with unexpected argument type");
OutOfLineStoreElementHole* ool =
@ -9677,7 +9677,7 @@ void CodeGenerator::emitStoreElementHoleT(T* lir) {
emitPreBarrier(elements, lir->index(), 0);
}
if (std::is_same<T, LFallibleStoreElementT>::value) {
if (std::is_same_v<T, LFallibleStoreElementT>) {
// If the object might be non-extensible, check for frozen elements and
// holes.
Address flags(elements, ObjectElements::offsetOfFlags());
@ -9703,8 +9703,8 @@ void CodeGenerator::visitStoreElementHoleT(LStoreElementHoleT* lir) {
template <typename T>
void CodeGenerator::emitStoreElementHoleV(T* lir) {
static_assert(std::is_same<T, LStoreElementHoleV>::value ||
std::is_same<T, LFallibleStoreElementV>::value,
static_assert(std::is_same_v<T, LStoreElementHoleV> ||
std::is_same_v<T, LFallibleStoreElementV>,
"emitStoreElementHoleV called with unexpected parameter type");
OutOfLineStoreElementHole* ool =
@ -9719,7 +9719,7 @@ void CodeGenerator::emitStoreElementHoleV(T* lir) {
Address initLength(elements, ObjectElements::offsetOfInitializedLength());
masm.spectreBoundsCheck32(index, initLength, spectreTemp, ool->entry());
if (std::is_same<T, LFallibleStoreElementV>::value) {
if (std::is_same_v<T, LFallibleStoreElementV>) {
// If the object might be non-extensible, check for frozen elements and
// holes.
Address flags(elements, ObjectElements::offsetOfFlags());
@ -13999,7 +13999,7 @@ void CodeGenerator::visitWasmAnyRefFromJSObject(LWasmAnyRefFromJSObject* lir) {
}
}
static_assert(!std::is_polymorphic<CodeGenerator>::value,
static_assert(!std::is_polymorphic_v<CodeGenerator>,
"CodeGenerator should not have any virtual methods");
} // namespace jit

View File

@ -189,9 +189,9 @@ bool JitRuntime::generateTrampolines(JSContext* cx) {
// The arguments rectifier has to use the same frame layout as the function
// frames it rectifies.
static_assert(std::is_base_of<JitFrameLayout, RectifierFrameLayout>::value,
static_assert(std::is_base_of_v<JitFrameLayout, RectifierFrameLayout>,
"a rectifier frame can be used with jit frame");
static_assert(std::is_base_of<JitFrameLayout, WasmToJSJitFrameLayout>::value,
static_assert(std::is_base_of_v<JitFrameLayout, WasmToJSJitFrameLayout>,
"wasm frames simply are jit frames");
static_assert(sizeof(JitFrameLayout) == sizeof(WasmToJSJitFrameLayout),
"thus a rectifier frame can be used with a wasm frame");

View File

@ -707,8 +707,8 @@ void LMoveGroup::printOperands(GenericPrinter& out) {
}
#endif
#define LIROP(x) \
static_assert(!std::is_polymorphic<L##x>::value, \
#define LIROP(x) \
static_assert(!std::is_polymorphic_v<L##x>, \
"LIR instructions should not have virtual methods");
LIR_OPCODE_LIST(LIROP)
#undef LIROP

View File

@ -5218,5 +5218,5 @@ void LIRGenerator::visitWasmFence(MWasmFence* ins) {
add(new (alloc()) LWasmFence, ins);
}
static_assert(!std::is_polymorphic<LIRGenerator>::value,
static_assert(!std::is_polymorphic_v<LIRGenerator>,
"LIRGenerator should not have any virtual methods");

View File

@ -19,7 +19,7 @@
using namespace js;
using namespace js::jit;
static_assert(!std::is_polymorphic<WarpOpSnapshot>::value,
static_assert(!std::is_polymorphic_v<WarpOpSnapshot>,
"WarpOpSnapshot should not have any virtual methods");
WarpSnapshot::WarpSnapshot(JSContext* cx, WarpScriptSnapshot* script)

View File

@ -209,8 +209,7 @@ class CodeGeneratorShared : public LElementVisitor {
template <typename T>
inline size_t allocateIC(const T& cache) {
static_assert(std::is_base_of<IonIC, T>::value,
"T must inherit from IonIC");
static_assert(std::is_base_of_v<IonIC, T>, "T must inherit from IonIC");
size_t index;
masm.propagateOOM(
allocateData(sizeof(mozilla::AlignedStorage2<T>), &index));

View File

@ -640,8 +640,8 @@ class MOZ_NONHEAP_CLASS Handle {
Handle(JS::Value value, Isolate* isolate);
// Constructor for handling automatic up casting.
template <typename S, typename = typename std::enable_if<
std::is_convertible<S*, T*>::value>::type>
template <typename S,
typename = std::enable_if_t<std::is_convertible_v<S*, T*>>>
inline Handle(Handle<S> handle) : location_(handle.location_) {}
template <typename S>
@ -705,8 +705,8 @@ class MOZ_NONHEAP_CLASS MaybeHandle final {
// Constructor for handling automatic up casting from Handle.
// Ex. Handle<JSArray> can be passed when MaybeHandle<Object> is expected.
template <typename S, typename = typename std::enable_if<
std::is_convertible<S*, T*>::value>::type>
template <typename S,
typename = std::enable_if_t<std::is_convertible_v<S*, T*>>>
MaybeHandle(Handle<S> handle) : location_(handle.location_) {}
inline Handle<T> ToHandleChecked() const {

View File

@ -11,7 +11,7 @@
#ifndef vm_AtomsTable_h
#define vm_AtomsTable_h
#include <type_traits> // std::{enable_if,is_const}
#include <type_traits> // std::{enable_if_t,is_const_v}
#include "js/GCHashTable.h"
#include "js/TypeDecls.h"
@ -173,8 +173,8 @@ class AtomsTable {
const mozilla::Maybe<uint32_t>& indexValue,
const AtomHasher::Lookup& lookup);
template <typename CharT, typename = typename std::enable_if<
!std::is_const<CharT>::value>::type>
template <typename CharT,
typename = std::enable_if_t<!std::is_const_v<CharT>>>
MOZ_ALWAYS_INLINE JSAtom* atomizeAndCopyChars(
JSContext* cx, CharT* chars, size_t length, PinningBehavior pin,
const mozilla::Maybe<uint32_t>& indexValue,

View File

@ -177,8 +177,8 @@ static const uint32_t INVALID_UTF8 = UINT32_MAX;
template <class InputCharsT>
static uint32_t Utf8ToOneUcs4CharImpl(const uint8_t* utf8Buffer,
int utf8Length) {
static_assert(std::is_same<InputCharsT, UTF8Chars>::value ||
std::is_same<InputCharsT, WTF8Chars>::value,
static_assert(std::is_same_v<InputCharsT, UTF8Chars> ||
std::is_same_v<InputCharsT, WTF8Chars>,
"must be either UTF-8 or WTF-8");
MOZ_ASSERT(1 <= utf8Length && utf8Length <= 4);
@ -204,7 +204,7 @@ static uint32_t Utf8ToOneUcs4CharImpl(const uint8_t* utf8Buffer,
}
// WTF-8 allows lone surrogate.
if (std::is_same<InputCharsT, UTF8Chars>::value &&
if (std::is_same_v<InputCharsT, UTF8Chars> &&
MOZ_UNLIKELY(IsSurrogate(ucs4Char))) {
return INVALID_UTF8;
}
@ -309,11 +309,11 @@ static bool InflateUTF8ToUTF16(JSContext* cx, const InputCharsT src,
(v == 0xF0 && ((uint8_t)src[i + 1] & 0xF0) == 0x80) || // F0 90~BF
(v == 0xF4 && ((uint8_t)src[i + 1] & 0xF0) != 0x80)) // F4 80~8F
{
if (std::is_same<InputCharsT, UTF8Chars>::value) {
if constexpr (std::is_same_v<InputCharsT, UTF8Chars>) {
INVALID(ReportInvalidCharacter, i, 1);
} else {
// WTF-8 allows lone surrogate as ED A0~BF 80~BF.
MOZ_ASSERT((std::is_same<InputCharsT, WTF8Chars>::value));
static_assert(std::is_same_v<InputCharsT, WTF8Chars>);
if (v == 0xED && ((uint8_t)src[i + 1] & 0xE0) != 0xA0) { // ED A0~BF
INVALID(ReportInvalidCharacter, i, 1);
}
@ -384,9 +384,9 @@ template <OnUTF8Error ErrorAction, typename CharsT, class InputCharsT>
static CharsT InflateUTF8StringHelper(JSContext* cx, const InputCharsT src,
size_t* outlen, arena_id_t destArenaId) {
using CharT = typename CharsT::CharT;
static_assert(std::is_same<CharT, char16_t>::value ||
std::is_same<CharT, Latin1Char>::value,
"bad CharT");
static_assert(
std::is_same_v<CharT, char16_t> || std::is_same_v<CharT, Latin1Char>,
"bad CharT");
*outlen = 0;
@ -411,7 +411,7 @@ static CharsT InflateUTF8StringHelper(JSContext* cx, const InputCharsT src,
}
constexpr OnUTF8Error errorMode =
std::is_same<CharT, Latin1Char>::value
std::is_same_v<CharT, Latin1Char>
? OnUTF8Error::InsertQuestionMark
: OnUTF8Error::InsertReplacementCharacter;
CopyAndInflateUTF8IntoBuffer<errorMode>(cx, src, dst, *outlen, allASCII);
@ -548,9 +548,9 @@ bool UTF8OrWTF8EqualsChars(const CharsT utfChars, const CharT* chars) {
#ifdef DEBUG
JS::SmallestEncoding encoding = JS::SmallestEncoding::ASCII;
UpdateSmallestEncodingForChar(c, &encoding);
if (std::is_same<CharT, JS::Latin1Char>::value) {
if (std::is_same_v<CharT, JS::Latin1Char>) {
MOZ_ASSERT(encoding <= JS::SmallestEncoding::Latin1);
} else if (!std::is_same<CharT, char16_t>::value) {
} else if (!std::is_same_v<CharT, char16_t>) {
MOZ_CRASH("Invalid character type in UTF8EqualsChars");
}
#endif

View File

@ -166,7 +166,7 @@ MOZ_MUST_USE T* UnwrapAndTypeCheckValueSlowPath(JSContext* cx,
template <class T, class ErrorCallback>
inline MOZ_MUST_USE T* UnwrapAndTypeCheckValue(JSContext* cx, HandleValue value,
ErrorCallback throwTypeError) {
static_assert(!std::is_convertible<T*, Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
cx->check(value);
if (value.isObject() && value.toObject().is<T>()) {
@ -234,7 +234,7 @@ inline MOZ_MUST_USE T* UnwrapAndTypeCheckArgument(JSContext* cx, CallArgs& args,
*/
template <class T>
MOZ_MUST_USE T* UnwrapAndDowncastObject(JSContext* cx, JSObject* obj) {
static_assert(!std::is_convertible<T*, Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
if (IsProxy(obj)) {
@ -287,7 +287,7 @@ template <class T>
inline MOZ_MUST_USE T* UnwrapInternalSlot(JSContext* cx,
Handle<NativeObject*> unwrappedObj,
uint32_t slot) {
static_assert(!std::is_convertible<T*, Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
return UnwrapAndDowncastValue<T>(cx, unwrappedObj->getFixedSlot(slot));

View File

@ -86,7 +86,7 @@ template <typename T>
static T* CreateEnvironmentObject(JSContext* cx, HandleShape shape,
HandleObjectGroup group, gc::InitialHeap heap,
IsSingletonEnv isSingleton) {
static_assert(std::is_base_of<EnvironmentObject, T>::value,
static_assert(std::is_base_of_v<EnvironmentObject, T>,
"T must be an EnvironmentObject");
// All environment objects can be background-finalized.

View File

@ -331,7 +331,7 @@ static bool ExpandErrorArgumentsHelper(JSContext* cx, JSErrorCallback callback,
}
if (efs) {
if constexpr (std::is_same<T, JSErrorReport>::value) {
if constexpr (std::is_same_v<T, JSErrorReport>) {
reportp->exnType = efs->exnType;
}

View File

@ -963,7 +963,7 @@ JSObject* GenericCreateConstructor(JSContext* cx, JSProtoKey key) {
template <typename T>
JSObject* GenericCreatePrototype(JSContext* cx, JSProtoKey key) {
static_assert(
!std::is_same<T, PlainObject>::value,
!std::is_same_v<T, PlainObject>,
"creating Object.prototype is very special and isn't handled here");
MOZ_ASSERT(&T::class_ == ProtoKeyToClass(key),
"type mismatch--probably too much copy/paste in your ClassSpec");

View File

@ -648,8 +648,7 @@ static MOZ_ALWAYS_INLINE JSAtom* AtomizeAndCopyCharsFromLookup(
JSContext* cx, Chars chars, size_t length, const AtomHasher::Lookup& lookup,
PinningBehavior pin, const Maybe<uint32_t>& indexValue);
template <typename CharT, typename = typename std::enable_if<
!std::is_const<CharT>::value>::type>
template <typename CharT, typename = std::enable_if_t<!std::is_const_v<CharT>>>
static MOZ_ALWAYS_INLINE JSAtom* AtomizeAndCopyCharsFromLookup(
JSContext* cx, CharT* chars, size_t length,
const AtomHasher::Lookup& lookup, PinningBehavior pin,
@ -663,8 +662,7 @@ static MOZ_NEVER_INLINE JSAtom* PermanentlyAtomizeAndCopyChars(
JSContext* cx, Maybe<AtomSet::AddPtr>& zonePtr, Chars chars, size_t length,
const Maybe<uint32_t>& indexValue, const AtomHasher::Lookup& lookup);
template <typename CharT, typename = typename std::enable_if<
!std::is_const<CharT>::value>::type>
template <typename CharT, typename = std::enable_if_t<!std::is_const_v<CharT>>>
static JSAtom* PermanentlyAtomizeAndCopyChars(
JSContext* cx, Maybe<AtomSet::AddPtr>& zonePtr, CharT* chars, size_t length,
const Maybe<uint32_t>& indexValue, const AtomHasher::Lookup& lookup) {
@ -745,8 +743,7 @@ static MOZ_ALWAYS_INLINE JSAtom* AllocateNewAtom(
JSContext* cx, Chars chars, size_t length, PinningBehavior pin,
const Maybe<uint32_t>& indexValue, const AtomHasher::Lookup& lookup);
template <typename CharT, typename = typename std::enable_if<
!std::is_const<CharT>::value>::type>
template <typename CharT, typename = std::enable_if_t<!std::is_const_v<CharT>>>
static MOZ_ALWAYS_INLINE JSAtom* AllocateNewAtom(
JSContext* cx, CharT* chars, size_t length, PinningBehavior pin,
const Maybe<uint32_t>& indexValue, const AtomHasher::Lookup& lookup) {
@ -1085,7 +1082,7 @@ JSAtom* AtomizeUTF8OrWTF8Chars(JSContext* cx, const char* utf8Chars,
AtomizeUTF8OrWTF8CharsWrapper<CharsT> chars(utf8, forCopy);
AtomHasher::Lookup lookup(utf8Chars, utf8ByteLength, length, hash);
if (std::is_same<CharsT, WTF8Chars>::value) {
if (std::is_same_v<CharsT, WTF8Chars>) {
lookup.type = AtomHasher::Lookup::WTF8;
}
return AtomizeAndCopyCharsFromLookup(cx, &chars, length, lookup, DoNotPinAtom,

View File

@ -616,7 +616,7 @@ MOZ_ALWAYS_INLINE JS::Handle<U*> js::HandleBase<JSObject*, Wrapper>::as()
template <class T>
bool JSObject::canUnwrapAs() {
static_assert(!std::is_convertible<T*, js::Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, js::Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
if (is<T>()) {
@ -628,7 +628,7 @@ bool JSObject::canUnwrapAs() {
template <class T>
T& JSObject::unwrapAs() {
static_assert(!std::is_convertible<T*, js::Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, js::Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
if (is<T>()) {
@ -645,7 +645,7 @@ T& JSObject::unwrapAs() {
template <class T>
T* JSObject::maybeUnwrapAs() {
static_assert(!std::is_convertible<T*, js::Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, js::Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
if (is<T>()) {
@ -666,7 +666,7 @@ T* JSObject::maybeUnwrapAs() {
template <class T>
T* JSObject::maybeUnwrapIf() {
static_assert(!std::is_convertible<T*, js::Wrapper*>::value,
static_assert(!std::is_convertible_v<T*, js::Wrapper*>,
"T can't be a Wrapper type; this function discards wrappers");
if (is<T>()) {

View File

@ -61,7 +61,7 @@ void SetFrameArgumentsObject(JSContext* cx, AbstractFramePtr frame,
inline void ScriptWarmUpData::initEnclosingScript(BaseScript* enclosingScript) {
MOZ_ASSERT(data_ == ResetState());
setTaggedPtr<EnclosingScriptTag>(enclosingScript);
static_assert(std::is_base_of<gc::TenuredCell, BaseScript>::value,
static_assert(std::is_base_of_v<gc::TenuredCell, BaseScript>,
"BaseScript must be TenuredCell to avoid post-barriers");
}
inline void ScriptWarmUpData::clearEnclosingScript() {
@ -72,7 +72,7 @@ inline void ScriptWarmUpData::clearEnclosingScript() {
inline void ScriptWarmUpData::initEnclosingScope(Scope* enclosingScope) {
MOZ_ASSERT(data_ == ResetState());
setTaggedPtr<EnclosingScopeTag>(enclosingScope);
static_assert(std::is_base_of<gc::TenuredCell, Scope>::value,
static_assert(std::is_base_of_v<gc::TenuredCell, Scope>,
"Scope must be TenuredCell to avoid post-barriers");
}
inline void ScriptWarmUpData::clearEnclosingScope() {

View File

@ -2946,9 +2946,9 @@ template <typename Unit, XDRMode mode>
/* static */
XDRResult ScriptSource::codeUncompressedData(XDRState<mode>* const xdr,
ScriptSource* const ss) {
static_assert(std::is_same<Unit, Utf8Unit>::value ||
std::is_same<Unit, char16_t>::value,
"should handle UTF-8 and UTF-16");
static_assert(
std::is_same_v<Unit, Utf8Unit> || std::is_same_v<Unit, char16_t>,
"should handle UTF-8 and UTF-16");
if (mode == XDR_ENCODE) {
MOZ_ASSERT(ss->isUncompressed<Unit>());
@ -2970,9 +2970,9 @@ template <typename Unit, XDRMode mode>
/* static */
XDRResult ScriptSource::codeCompressedData(XDRState<mode>* const xdr,
ScriptSource* const ss) {
static_assert(std::is_same<Unit, Utf8Unit>::value ||
std::is_same<Unit, char16_t>::value,
"should handle UTF-8 and UTF-16");
static_assert(
std::is_same_v<Unit, Utf8Unit> || std::is_same_v<Unit, char16_t>,
"should handle UTF-8 and UTF-16");
if (mode == XDR_ENCODE) {
MOZ_ASSERT(ss->isCompressed<Unit>());
@ -3020,9 +3020,9 @@ template <typename Unit,
XDRMode mode>
/* static */
void ScriptSource::codeRetrievable(ScriptSource* const ss) {
static_assert(std::is_same<Unit, Utf8Unit>::value ||
std::is_same<Unit, char16_t>::value,
"should handle UTF-8 and UTF-16");
static_assert(
std::is_same_v<Unit, Utf8Unit> || std::is_same_v<Unit, char16_t>,
"should handle UTF-8 and UTF-16");
if (mode == XDR_ENCODE) {
MOZ_ASSERT((ss->data.is<Data<Unit, SourceRetrievable::Yes>>()));

View File

@ -221,8 +221,8 @@ using SourceData = mozilla::UniquePtr<void, JS::FreePolicy>;
template <typename Unit>
inline SourceData ToSourceData(EntryUnits<Unit> chars) {
static_assert(std::is_same<SourceData::DeleterType,
typename EntryUnits<Unit>::DeleterType>::value,
static_assert(std::is_same_v<SourceData::DeleterType,
typename EntryUnits<Unit>::DeleterType>,
"EntryUnits and SourceData must share the same deleter "
"type, that need not know the type of the data being freed, "
"for the upcast below to be safe");

View File

@ -371,7 +371,7 @@ class BaseScopeData {};
template <class Data>
inline size_t SizeOfData(uint32_t numBindings) {
static_assert(std::is_base_of<BaseScopeData, Data>::value,
static_assert(std::is_base_of_v<BaseScopeData, Data>,
"Data must be the correct sort of data, i.e. it must "
"inherit from BaseScopeData");
return sizeof(Data) +

View File

@ -228,7 +228,7 @@ inline GCPtrShape* DictionaryShapeLink::prevPtr() {
template <class ObjectSubclass>
/* static */ inline bool EmptyShape::ensureInitialCustomShape(
JSContext* cx, Handle<ObjectSubclass*> obj) {
static_assert(std::is_base_of<JSObject, ObjectSubclass>::value,
static_assert(std::is_base_of_v<JSObject, ObjectSubclass>,
"ObjectSubclass must be a subclass of JSObject");
// If the provided object has a non-empty shape, it was given the cached

View File

@ -106,8 +106,7 @@ static MOZ_ALWAYS_INLINE JSLinearString* TryEmptyOrStaticString(JSContext* cx,
return nullptr;
}
template <typename CharT, typename = typename std::enable_if<
!std::is_const<CharT>::value>::type>
template <typename CharT, typename = std::enable_if_t<!std::is_const_v<CharT>>>
static MOZ_ALWAYS_INLINE JSLinearString* TryEmptyOrStaticString(JSContext* cx,
CharT* chars,
size_t n) {

View File

@ -1315,9 +1315,9 @@ class StaticStrings {
/* Return null if no static atom exists for the given (chars, length). */
template <typename Chars>
MOZ_ALWAYS_INLINE JSAtom* lookup(Chars chars, size_t length) {
static_assert(std::is_same<Chars, const Latin1Char*>::value ||
std::is_same<Chars, const char16_t*>::value ||
std::is_same<Chars, LittleEndianChars>::value,
static_assert(std::is_same_v<Chars, const Latin1Char*> ||
std::is_same_v<Chars, const char16_t*> ||
std::is_same_v<Chars, LittleEndianChars>,
"for understandability, |chars| must be one of a few "
"identified types");
@ -1366,8 +1366,8 @@ class StaticStrings {
return lookup(reinterpret_cast<const Latin1Char*>(chars), length);
}
template <typename CharT, typename = typename std::enable_if<
!std::is_const<CharT>::value>::type>
template <typename CharT,
typename = std::enable_if_t<!std::is_const_v<CharT>>>
MOZ_ALWAYS_INLINE JSAtom* lookup(CharT* chars, size_t length) {
// Collapse the remaining |CharT*| to |const CharT*| to avoid excess
// instantiations.

View File

@ -692,12 +692,12 @@ class ElementSpecific {
return true;
}
if (std::is_same<T, int64_t>::value) {
if (std::is_same_v<T, int64_t>) {
JS_TRY_VAR_OR_RETURN_FALSE(cx, *result, ToBigInt64(cx, v));
return true;
}
if (std::is_same<T, uint64_t>::value) {
if (std::is_same_v<T, uint64_t>) {
JS_TRY_VAR_OR_RETURN_FALSE(cx, *result, ToBigUint64(cx, v));
return true;
}

View File

@ -51,7 +51,7 @@ XDRResult XDRState<mode>::codeChars(Latin1Char* chars, size_t nchars) {
static_assert(sizeof(Latin1Char) == 1,
"Latin1Char must be 1 byte for nchars below to be the "
"proper count of bytes");
static_assert(std::is_same<Latin1Char, unsigned char>::value,
static_assert(std::is_same_v<Latin1Char, unsigned char>,
"Latin1Char must be unsigned char to C++-safely reinterpret "
"the bytes generically copied below as Latin1Char");
return codeBytes(chars, nchars);

View File

@ -170,7 +170,7 @@ struct LitValPOD {
}
};
static_assert(std::is_pod<LitValPOD>::value,
static_assert(std::is_pod_v<LitValPOD>,
"must be POD to be simply serialized/deserialized");
// An AsmJSGlobal represents a JS global variable in the asm.js module function.

View File

@ -271,7 +271,7 @@ class Opcode {
enum class PackedTypeCode : uint32_t {};
static_assert(std::is_pod<PackedTypeCode>::value,
static_assert(std::is_pod_v<PackedTypeCode>,
"must be POD to be simply serialized/deserialized");
const uint32_t NoTypeCode = 0xFF; // Only use these

View File

@ -369,7 +369,7 @@ XrayTraits* GetXrayTraits(JSObject* obj);
template <typename Base, typename Traits>
class XrayWrapper : public Base {
static_assert(std::is_base_of<js::BaseProxyHandler, Base>::value,
static_assert(std::is_base_of_v<js::BaseProxyHandler, Base>,
"Base *must* derive from js::BaseProxyHandler");
public: