diff --git a/accessible/windows/ProxyWrappers.h b/accessible/windows/ProxyWrappers.h index 5fcc2a4fd75a..38b0981b0987 100644 --- a/accessible/windows/ProxyWrappers.h +++ b/accessible/windows/ProxyWrappers.h @@ -81,7 +81,7 @@ class DocProxyAccessibleWrap : public HyperTextProxyAccessibleWrap { template inline ProxyAccessible* HyperTextProxyFor(T* aWrapper) { - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "only IAccessible* should be passed in"); auto wrapper = static_cast(aWrapper); return wrapper->IsProxy() ? wrapper->Proxy() : nullptr; diff --git a/dom/bindings/BindingDeclarations.h b/dom/bindings/BindingDeclarations.h index 988af16d260f..d946e75825c8 100644 --- a/dom/bindings/BindingDeclarations.h +++ b/dom/bindings/BindingDeclarations.h @@ -61,13 +61,13 @@ struct DictionaryBase { }; template -inline typename EnableIf::value, void>::Type +inline typename EnableIf::value, void>::Type ImplCycleCollectionUnlink(T& aDictionary) { aDictionary.UnlinkForCC(); } template -inline typename EnableIf::value, void>::Type +inline typename EnableIf::value, void>::Type ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, T& aDictionary, const char* aName, uint32_t aFlags = 0) { diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index b609fdffaa33..ffd948e350c1 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -823,7 +823,7 @@ struct IsRefcounted { // This struct only works if T is fully declared (not just forward declared). // The IsBaseOf check will ensure that, we don't really need it for any other // reason (the static assert will of course always be true). - static_assert(!IsBaseOf::value || IsRefcounted::value, + static_assert(!std::is_base_of::value || IsRefcounted::value, "Classes derived from nsISupports are refcounted!"); }; @@ -832,7 +832,7 @@ struct IsRefcounted { #undef HAS_MEMBER_TYPEDEFS #ifdef DEBUG -template ::value> +template ::value> struct CheckWrapperCacheCast { static bool Check() { return reinterpret_cast( @@ -982,13 +982,13 @@ template struct TypeNeedsOuterization { // We only need to outerize Window objects, so anything inheriting from // nsGlobalWindow (which inherits from EventTarget itself). - static const bool value = IsBaseOf::value || - IsBaseOf::value || + static const bool value = std::is_base_of::value || + std::is_base_of::value || IsSame::value; }; #ifdef DEBUG -template ::value> +template ::value> struct CheckWrapperCacheTracing { static inline void Check(T* aObject) {} }; @@ -1058,7 +1058,7 @@ MOZ_ALWAYS_INLINE bool DoGetOrCreateDOMReflector( } #ifdef DEBUG - if (IsBaseOf::value) { + if (std::is_base_of::value) { CheckWrapperCacheTracing::Check(value); } #endif @@ -1076,7 +1076,7 @@ MOZ_ALWAYS_INLINE bool DoGetOrCreateDOMReflector( // reinterpret_castable to nsWrapperCache. MOZ_ASSERT(clasp, "What happened here?"); MOZ_ASSERT_IF(clasp->mDOMObjectIsISupports, - (IsBaseOf::value)); + (std::is_base_of::value)); MOZ_ASSERT(CheckWrapperCacheCast::Check()); } #endif @@ -1907,9 +1907,10 @@ void DoTraceSequence(JSTracer* trc, nsTArray& seq); // Class used to trace sequences, with specializations for various // sequence types. -template ::value, - bool isTypedArray = IsBaseOf::value, - bool isOwningUnion = IsBaseOf::value> +template ::value, + bool isTypedArray = std::is_base_of::value, + bool isOwningUnion = std::is_base_of::value> class SequenceTracer { explicit SequenceTracer() = delete; // Should never be instantiated }; @@ -2529,7 +2530,7 @@ inline bool UTF8StringToJsval(JSContext* cx, const nsACString& str, return NonVoidUTF8StringToJsval(cx, str, rval); } -template ::value> +template ::value> struct PreserveWrapperHelper { static void PreserveWrapper(T* aObject) { aObject->PreserveWrapper(aObject, NS_CYCLE_COLLECTION_PARTICIPANT(T)); @@ -2548,7 +2549,7 @@ void PreserveWrapper(T* aObject) { PreserveWrapperHelper::PreserveWrapper(aObject); } -template ::value> +template ::value> struct CastingAssertions { static bool ToSupportsIsCorrect(T*) { return true; } static bool ToSupportsIsOnPrimaryInheritanceChain(T*, nsWrapperCache*) { @@ -2663,7 +2664,7 @@ class MOZ_STACK_CLASS BindingJSObjectCreator { struct OwnedNative { // Make sure the native objects inherit from NonRefcountedDOMObject so // that we log their ctor and dtor. - static_assert(IsBaseOf::value, + static_assert(std::is_base_of::value, "Non-refcounted objects with DOM bindings should inherit " "from NonRefcountedDOMObject."); @@ -2699,7 +2700,7 @@ struct DeferredFinalizerImpl { typedef SegmentedVector SmartPtrArray; static_assert( - IsSame::value || !IsBaseOf::value, + IsSame::value || !std::is_base_of::value, "nsISupports classes should all use the nsISupports instantiation"); static inline void AppendAndTake( @@ -2742,7 +2743,7 @@ struct DeferredFinalizerImpl { } }; -template ::value> +template ::value> struct DeferredFinalizer { static void AddForDeferredFinalization(T* aObject) { typedef DeferredFinalizerImpl Impl; @@ -2766,7 +2767,7 @@ static void AddForDeferredFinalization(T* aObject) { // This returns T's CC participant if it participates in CC and does not inherit // from nsISupports. Otherwise, it returns null. QI should be used to get the // participant if T inherits from nsISupports. -template ::value> +template ::value> class GetCCParticipant { // Helper for GetCCParticipant for classes that participate in CC. template @@ -2825,8 +2826,8 @@ struct CreateGlobalOptionsWithXPConnect { template using IsGlobalWithXPConnect = - IntegralConstant::value || - IsBaseOf::value>; + IntegralConstant::value || + std::is_base_of::value>; template struct CreateGlobalOptions : Conditional::value, diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index d5c7981fe747..b7ec5d26f7aa 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -440,7 +440,7 @@ def DOMClass(descriptor): return fill( """ { ${protoChain} }, - IsBaseOf::value, + std::is_base_of::value, ${hooks}, FindAssociatedGlobalForNative<${nativeType}>::Get, GetProtoObjectHandle, @@ -3887,7 +3887,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod): return fill( """ - static_assert(!IsBaseOf::value, + static_assert(!std::is_base_of::value, "Shouldn't have wrappercached things that are not refcounted."); $*{assertInheritance} MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); @@ -13607,7 +13607,7 @@ class CGDescriptor(CGThing): if descriptor.proxy: cgThings.append(CGGeneric(fill( """ - static_assert(IsBaseOf::value, + static_assert(std::is_base_of::value, "We don't support non-nsISupports native classes for " "proxy-based bindings yet"); diff --git a/dom/bindings/ToJSValue.h b/dom/bindings/ToJSValue.h index 54890c37bef6..6c9ef58817ca 100644 --- a/dom/bindings/ToJSValue.h +++ b/dom/bindings/ToJSValue.h @@ -118,8 +118,10 @@ MOZ_MUST_USE inline bool ToJSValue(JSContext* aCx, CallbackObject& aArgument, // Accept objects that inherit from nsWrapperCache (e.g. most // DOM objects). template -MOZ_MUST_USE typename EnableIf::value, bool>::Type -ToJSValue(JSContext* aCx, T& aArgument, JS::MutableHandle aValue) { +MOZ_MUST_USE + typename EnableIf::value, bool>::Type + ToJSValue(JSContext* aCx, T& aArgument, + JS::MutableHandle aValue) { // Make sure we're called in a compartment MOZ_ASSERT(JS::CurrentGlobalOrNull(aCx)); @@ -132,7 +134,8 @@ ToJSValue(JSContext* aCx, T& aArgument, JS::MutableHandle aValue) { namespace binding_detail { template MOZ_MUST_USE - typename EnableIf::value, bool>::Type + typename EnableIf::value, + bool>::Type ToJSValueFromPointerHelper(JSContext* aCx, T* aArgument, JS::MutableHandle aValue) { // Make sure we're called in a compartment @@ -160,7 +163,8 @@ MOZ_MUST_USE // nsAutoPtr. template MOZ_MUST_USE - typename EnableIf::value, bool>::Type + typename EnableIf::value, + bool>::Type ToJSValue(JSContext* aCx, nsAutoPtr&& aArgument, JS::MutableHandle aValue) { if (!binding_detail::ToJSValueFromPointerHelper(aCx, aArgument.get(), @@ -177,7 +181,8 @@ MOZ_MUST_USE // UniquePtr. template MOZ_MUST_USE - typename EnableIf::value, bool>::Type + typename EnableIf::value, + bool>::Type ToJSValue(JSContext* aCx, UniquePtr&& aArgument, JS::MutableHandle aValue) { if (!binding_detail::ToJSValueFromPointerHelper(aCx, aArgument.get(), @@ -193,7 +198,7 @@ MOZ_MUST_USE // Accept typed arrays built from appropriate nsTArray values template MOZ_MUST_USE - typename EnableIf::value, bool>::Type + typename EnableIf::value, bool>::Type ToJSValue(JSContext* aCx, const TypedArrayCreator& aArgument, JS::MutableHandle aValue) { // Make sure we're called in a compartment @@ -210,9 +215,9 @@ MOZ_MUST_USE // Accept objects that inherit from nsISupports but not nsWrapperCache (e.g. // DOM File). template -MOZ_MUST_USE typename EnableIf::value && - !IsBaseOf::value && - IsBaseOf::value, +MOZ_MUST_USE typename EnableIf::value && + !std::is_base_of::value && + std::is_base_of::value, bool>::Type ToJSValue(JSContext* aCx, T& aArgument, JS::MutableHandle aValue) { // Make sure we're called in a compartment @@ -247,9 +252,10 @@ MOZ_MUST_USE bool ToJSValue(JSContext* aCx, const NonNull& aArgument, // Accept WebIDL dictionaries template -MOZ_MUST_USE typename EnableIf::value, bool>::Type -ToJSValue(JSContext* aCx, const T& aArgument, - JS::MutableHandle aValue) { +MOZ_MUST_USE + typename EnableIf::value, bool>::Type + ToJSValue(JSContext* aCx, const T& aArgument, + JS::MutableHandle aValue) { return aArgument.ToObjectInternal(aCx, aValue); } @@ -306,7 +312,7 @@ MOZ_MUST_USE bool ToJSValue(JSContext* aCx, ErrorResult& aArgument, // Accept owning WebIDL unions. template MOZ_MUST_USE - typename EnableIf::value, bool>::Type + typename EnableIf::value, bool>::Type ToJSValue(JSContext* aCx, const T& aArgument, JS::MutableHandle aValue) { JS::Rooted global(aCx, JS::CurrentGlobalOrNull(aCx)); diff --git a/gfx/2d/DrawingJob.h b/gfx/2d/DrawingJob.h index ba5324c9058b..870d81616f02 100644 --- a/gfx/2d/DrawingJob.h +++ b/gfx/2d/DrawingJob.h @@ -68,7 +68,7 @@ class CommandBufferBuilder { /// This must be used between BeginCommandBuffer and EndCommandBuffer. template ptrdiff_t AddCommand(Args&&... aArgs) { - static_assert(IsBaseOf::value, + static_assert(std::is_base_of::value, "T must derive from DrawingCommand"); return mCommands->mStorage.Alloc(std::forward(aArgs)...); } diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index 93b63b5956d4..47ecfc14be21 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -322,9 +322,8 @@ class StackFrame { template void construct(T* ptr) { - static_assert( - mozilla::IsBaseOf>::value, - "ConcreteStackFrame must inherit from BaseStackFrame"); + static_assert(std::is_base_of>::value, + "ConcreteStackFrame must inherit from BaseStackFrame"); static_assert( sizeof(ConcreteStackFrame) == sizeof(*base()), "ubi::ConcreteStackFrame specializations must be the same size as " @@ -711,7 +710,7 @@ class Node { static_assert( sizeof(Concrete) == sizeof(*base()), "ubi::Base specializations must be the same size as ubi::Base"); - static_assert(mozilla::IsBaseOf>::value, + static_assert(std::is_base_of>::value, "ubi::Concrete must inherit from ubi::Base"); Concrete::construct(base(), ptr); } diff --git a/js/src/frontend/BinASTParserPerTokenizer.cpp b/js/src/frontend/BinASTParserPerTokenizer.cpp index 298175e177e3..3e4bde7f0227 100644 --- a/js/src/frontend/BinASTParserPerTokenizer.cpp +++ b/js/src/frontend/BinASTParserPerTokenizer.cpp @@ -789,7 +789,7 @@ BinASTParserPerTokenizer::asFinalParser() { // Same as GeneralParser::asFinalParser, verify the inheritance to // make sure the static downcast works. static_assert( - mozilla::IsBaseOf, FinalParser>::value, + std::is_base_of, FinalParser>::value, "inheritance relationship required by the static_cast<> below"); return static_cast(this); @@ -799,7 +799,7 @@ template inline const typename BinASTParserPerTokenizer::FinalParser* BinASTParserPerTokenizer::asFinalParser() const { static_assert( - mozilla::IsBaseOf, FinalParser>::value, + std::is_base_of, FinalParser>::value, "inheritance relationship required by the static_cast<> below"); return static_cast(this); diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index a4f8f026326f..855122eaefe0 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -108,7 +108,7 @@ template inline typename GeneralParser::FinalParser* GeneralParser::asFinalParser() { static_assert( - mozilla::IsBaseOf, FinalParser>::value, + std::is_base_of, FinalParser>::value, "inheritance relationship required by the static_cast<> below"); return static_cast(this); @@ -118,7 +118,7 @@ template inline const typename GeneralParser::FinalParser* GeneralParser::asFinalParser() const { static_assert( - mozilla::IsBaseOf, FinalParser>::value, + std::is_base_of, FinalParser>::value, "inheritance relationship required by the static_cast<> below"); return static_cast(this); diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 8cf29e175682..f658d9e154f9 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -1825,7 +1825,7 @@ ParserAnyCharsAccess::anyChars(const GeneralTokenStreamChars* ts) { // member within. static_assert( - mozilla::IsBaseOf::value, + std::is_base_of::value, "the static_cast<> below assumes a base-class relationship"); const auto* tss = static_cast(ts); diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h index dcedf75359b6..ada1132b82e5 100644 --- a/js/src/frontend/TokenStream.h +++ b/js/src/frontend/TokenStream.h @@ -1902,7 +1902,7 @@ class GeneralTokenStreamChars : public SpecializedTokenStreamCharsBase { TokenStreamSpecific* asSpecific() { static_assert( - mozilla::IsBaseOf::value, + std::is_base_of::value, "static_cast below presumes an inheritance relationship"); return static_cast(this); diff --git a/js/src/gc/Marking-inl.h b/js/src/gc/Marking-inl.h index 2ea25daeba19..d56e95fff59c 100644 --- a/js/src/gc/Marking-inl.h +++ b/js/src/gc/Marking-inl.h @@ -33,7 +33,7 @@ struct TaggedPtr { static JS::Value wrap(JS::BigInt* bi) { return JS::BigIntValue(bi); } template static JS::Value wrap(T* priv) { - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Type must be a GC thing derived from js::gc::Cell"); return JS::PrivateGCThingValue(priv); } @@ -57,20 +57,20 @@ struct TaggedPtr { template struct MightBeForwarded { - static_assert(mozilla::IsBaseOf::value, "T must derive from Cell"); + static_assert(std::is_base_of::value, "T must derive from Cell"); static_assert(!mozilla::IsSame::value && !mozilla::IsSame::value, "T must not be Cell or TenuredCell"); - static const bool value = mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value; + static const bool value = std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value; }; template diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 3d42a52c128e..83c584591a91 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -3610,9 +3610,9 @@ static inline bool ShouldCheckMarkState(JSRuntime* rt, T** thingp) { template struct MightBeNurseryAllocated { - static const bool value = mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value || - mozilla::IsBaseOf::value; + static const bool value = std::is_base_of::value || + std::is_base_of::value || + std::is_base_of::value; }; template diff --git a/js/src/gc/Policy.h b/js/src/gc/Policy.h index 1cf200fa9bfb..6f7225ebc265 100644 --- a/js/src/gc/Policy.h +++ b/js/src/gc/Policy.h @@ -22,7 +22,7 @@ struct InternalGCPointerPolicy : public JS::GCPointerPolicy { using Type = typename mozilla::RemovePointer::Type; #define IS_BASE_OF_OR(_1, BaseType, _2, _3) \ - mozilla::IsBaseOf::value || + std::is_base_of::value || static_assert( JS_FOR_EACH_TRACEKIND(IS_BASE_OF_OR) false, "InternalGCPointerPolicy must only be used for GC thing pointers"); diff --git a/js/src/gc/Tracer.h b/js/src/gc/Tracer.h index bd8731aed982..ba835cab6801 100644 --- a/js/src/gc/Tracer.h +++ b/js/src/gc/Tracer.h @@ -68,7 +68,7 @@ template struct BaseGCType { using type = typename MapTraceKindToType::kind>::Type; - static_assert(mozilla::IsBaseOf::value, "Failed to find base type"); + static_assert(std::is_base_of::value, "Failed to find base type"); }; // Our barrier templates are parameterized on the pointer types so that we can diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index 55683cc3cf23..8d88504677b7 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -265,11 +265,10 @@ bool JitRuntime::generateTrampolines(JSContext* cx) { // The arguments rectifier has to use the same frame layout as the function // frames it rectifies. - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "a rectifier frame can be used with jit frame"); - static_assert( - mozilla::IsBaseOf::value, - "wasm frames simply are jit frames"); + static_assert(std::is_base_of::value, + "wasm frames simply are jit frames"); static_assert(sizeof(JitFrameLayout) == sizeof(WasmToJSJitFrameLayout), "thus a rectifier frame can be used with a wasm frame"); diff --git a/js/src/jit/shared/CodeGenerator-shared.h b/js/src/jit/shared/CodeGenerator-shared.h index fbbc393516fe..900ad15f5eb4 100644 --- a/js/src/jit/shared/CodeGenerator-shared.h +++ b/js/src/jit/shared/CodeGenerator-shared.h @@ -226,7 +226,7 @@ class CodeGeneratorShared : public LElementVisitor { template inline size_t allocateIC(const T& cache) { - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "T must inherit from IonIC"); size_t index; masm.propagateOOM( diff --git a/js/src/vm/Scope.h b/js/src/vm/Scope.h index 2cd547703537..e680cbfe5bfc 100644 --- a/js/src/vm/Scope.h +++ b/js/src/vm/Scope.h @@ -361,7 +361,7 @@ class BaseScopeData {}; template inline size_t SizeOfData(uint32_t numBindings) { - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Data must be the correct sort of data, i.e. it must " "inherit from BaseScopeData"); return sizeof(Data) + diff --git a/js/src/vm/Shape-inl.h b/js/src/vm/Shape-inl.h index 8b32c19072dd..71bd78b932b1 100644 --- a/js/src/vm/Shape-inl.h +++ b/js/src/vm/Shape-inl.h @@ -230,7 +230,7 @@ inline GCPtrShape* DictionaryShapeLink::prevPtr() { template /* static */ inline bool EmptyShape::ensureInitialCustomShape( JSContext* cx, Handle obj) { - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "ObjectSubclass must be a subclass of JSObject"); // If the provided object has a non-empty shape, it was given the cached diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h index e94fc559fdde..e862560c1835 100644 --- a/js/xpconnect/wrappers/XrayWrapper.h +++ b/js/xpconnect/wrappers/XrayWrapper.h @@ -369,7 +369,7 @@ XrayTraits* GetXrayTraits(JSObject* obj); template class XrayWrapper : public Base { - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Base *must* derive from js::BaseProxyHandler"); public: diff --git a/layout/generic/nsQueryFrame.h b/layout/generic/nsQueryFrame.h index f48243f29875..d822cf25143b 100644 --- a/layout/generic/nsQueryFrame.h +++ b/layout/generic/nsQueryFrame.h @@ -127,9 +127,8 @@ class do_QueryFrameHelper { template struct FastQueryFrame< Src, Dst, - typename mozilla::EnableIf::value>::Type, - typename mozilla::EnableIf< - mozilla::IsBaseOf::value>::Type> { + typename mozilla::EnableIf::value>::Type, + typename mozilla::EnableIf::value>::Type> { static Dst* QueryFrame(Src* aFrame) { return nsQueryFrame::FrameIID(aFrame->mClass) == Dst::kFrameIID ? reinterpret_cast(aFrame) diff --git a/mfbt/ArrayUtils.h b/mfbt/ArrayUtils.h index 4da0fa4f6035..04ccffe38294 100644 --- a/mfbt/ArrayUtils.h +++ b/mfbt/ArrayUtils.h @@ -131,7 +131,7 @@ struct AlignedChecker { * particular alignment). */ template -inline typename EnableIf::value || IsBaseOf::value || +inline typename EnableIf::value || std::is_base_of::value || IsVoid::value, bool>::Type IsInRange(const T* aPtr, const U* aBegin, const U* aEnd) { diff --git a/mfbt/DoublyLinkedList.h b/mfbt/DoublyLinkedList.h index 98e43e805ef9..0b93f85ff228 100644 --- a/mfbt/DoublyLinkedList.h +++ b/mfbt/DoublyLinkedList.h @@ -93,7 +93,7 @@ class DoublyLinkedListElement { */ template struct GetDoublyLinkedListElement { - static_assert(mozilla::IsBaseOf, T>::value, + static_assert(std::is_base_of, T>::value, "You need your own specialization of GetDoublyLinkedListElement" " or use a separate Trait."); static DoublyLinkedListElement& Get(T* aThis) { return *aThis; } diff --git a/mfbt/Pair.h b/mfbt/Pair.h index ef6b4d1f27f9..aa77eec3b26a 100644 --- a/mfbt/Pair.h +++ b/mfbt/Pair.h @@ -26,13 +26,13 @@ enum StorageType { AsBase, AsMember }; // The extra conditions on storage for B are necessary so that PairHelper won't // ambiguously inherit from either A or B, such that one or the other base class // would be inaccessible. -template ::value ? detail::AsBase : detail::AsMember, - detail::StorageType = IsEmpty::value && !IsBaseOf::value && - !IsBaseOf::value - ? detail::AsBase - : detail::AsMember> +template < + typename A, typename B, + detail::StorageType = IsEmpty::value ? detail::AsBase : detail::AsMember, + detail::StorageType = IsEmpty::value && !std::is_base_of::value && + !std::is_base_of::value + ? detail::AsBase + : detail::AsMember> struct PairHelper; template diff --git a/mfbt/RefCounted.h b/mfbt/RefCounted.h index 6f70696d1a3a..bd18a451a920 100644 --- a/mfbt/RefCounted.h +++ b/mfbt/RefCounted.h @@ -245,7 +245,7 @@ template class RefCounted : public detail::RefCounted { public: ~RefCounted() { - static_assert(IsBaseOf::value, + static_assert(std::is_base_of::value, "T must derive from RefCounted"); } }; @@ -266,7 +266,7 @@ class AtomicRefCounted Recording> { public: ~AtomicRefCounted() { - static_assert(IsBaseOf::value, + static_assert(std::is_base_of::value, "T must derive from AtomicRefCounted"); } }; diff --git a/mfbt/ThreadSafeWeakPtr.h b/mfbt/ThreadSafeWeakPtr.h index e305b2c54ac6..355c8ee2504c 100644 --- a/mfbt/ThreadSafeWeakPtr.h +++ b/mfbt/ThreadSafeWeakPtr.h @@ -221,7 +221,7 @@ class SupportsThreadSafeWeakPtr : public external::AtomicRefCounted { // that the object may be of an actual derived type U, but the weak reference // is created for the supplied type T of SupportsThreadSafeWeakPtr. already_AddRefed getThreadSafeWeakReference() { - static_assert(IsBaseOf, T>::value, + static_assert(std::is_base_of, T>::value, "T must derive from SupportsThreadSafeWeakPtr"); if (!mRef) { @@ -312,9 +312,9 @@ class ThreadSafeWeakPtr { private: // Gets a new strong reference of the proper type T to the tracked object. already_AddRefed getRefPtr() const { - static_assert( - IsBaseOf::value, - "T must derive from ThreadSafeWeakReference::ElementType"); + static_assert(std::is_base_of::value, + "T must derive from ThreadSafeWeakReference::ElementType"); return mRef ? mRef->getRefPtr().template downcast() : nullptr; } @@ -322,9 +322,9 @@ class ThreadSafeWeakPtr { // Note that this operation is unsafe as it may cause races if downwind // code depends on the value not to change after reading. T* get() const { - static_assert( - IsBaseOf::value, - "T must derive from ThreadSafeWeakReference::ElementType"); + static_assert(std::is_base_of::value, + "T must derive from ThreadSafeWeakReference::ElementType"); return mRef ? static_cast(mRef->get()) : nullptr; } diff --git a/mfbt/TypeTraits.h b/mfbt/TypeTraits.h index 9bb088527861..63965b044797 100644 --- a/mfbt/TypeTraits.h +++ b/mfbt/TypeTraits.h @@ -728,9 +728,9 @@ struct BaseOfTester : TrueType {}; * class B : public A {}; * class C {}; * - * mozilla::IsBaseOf::value is true; - * mozilla::IsBaseOf::value is true; - * mozilla::IsBaseOf::value is false; + * std::is_base_of::value is true; + * std::is_base_of::value is true; + * std::is_base_of::value is false; */ template struct IsBaseOf diff --git a/mfbt/WeakPtr.h b/mfbt/WeakPtr.h index b2851d471a06..c0b1432ef3aa 100644 --- a/mfbt/WeakPtr.h +++ b/mfbt/WeakPtr.h @@ -215,7 +215,7 @@ template class SupportsWeakPtr { protected: ~SupportsWeakPtr() { - static_assert(IsBaseOf, T>::value, + static_assert(std::is_base_of, T>::value, "T must derive from SupportsWeakPtr"); if (mSelfReferencingWeakPtr) { mSelfReferencingWeakPtr.mRef->detach(); diff --git a/mfbt/tests/TestTypeTraits.cpp b/mfbt/tests/TestTypeTraits.cpp index ea1f94bcd487..eeb370514ab1 100644 --- a/mfbt/tests/TestTypeTraits.cpp +++ b/mfbt/tests/TestTypeTraits.cpp @@ -427,22 +427,23 @@ struct B2 : B {}; struct D : private B1, private B2 {}; static void StandardIsBaseOfTests() { - static_assert((IsBaseOf::value) == true, "IsBaseOf fails on diamond"); - static_assert((IsBaseOf::value) == true, + static_assert((std::is_base_of::value) == true, + "IsBaseOf fails on diamond"); + static_assert((std::is_base_of::value) == true, "IsBaseOf fails on diamond plus constness change"); - static_assert((IsBaseOf::value) == true, + static_assert((std::is_base_of::value) == true, "IsBaseOf fails on diamond plus constness change"); - static_assert((IsBaseOf::value) == true, + static_assert((std::is_base_of::value) == true, "IsBaseOf fails on constness change"); - static_assert((IsBaseOf::value) == false, + static_assert((std::is_base_of::value) == false, "IsBaseOf got the direction of inheritance wrong"); - static_assert((IsBaseOf::value) == false, + static_assert((std::is_base_of::value) == false, "IsBaseOf should return false on references"); - static_assert((IsBaseOf::value) == false, + static_assert((std::is_base_of::value) == false, "IsBaseOf should return false on arrays"); // We fail at the following test. To fix it, we need to specialize IsBaseOf // for all built-in types. - // static_assert((IsBaseOf::value) == false); + // static_assert((std::is_base_of::value) == false); } } /* namespace CPlusPlus11IsBaseOf */ @@ -455,15 +456,15 @@ class E : public A {}; class F : public B, public E {}; static void TestIsBaseOf() { - static_assert((IsBaseOf::value), "A is a base of B"); - static_assert((!IsBaseOf::value), "B is not a base of A"); - static_assert((IsBaseOf::value), "A is a base of C"); - static_assert((!IsBaseOf::value), "C is not a base of A"); - static_assert((IsBaseOf::value), "A is a base of F"); - static_assert((!IsBaseOf::value), "F is not a base of A"); - static_assert((!IsBaseOf::value), "A is not a base of D"); - static_assert((!IsBaseOf::value), "D is not a base of A"); - static_assert((IsBaseOf::value), + static_assert((std::is_base_of::value), "A is a base of B"); + static_assert((!std::is_base_of::value), "B is not a base of A"); + static_assert((std::is_base_of::value), "A is a base of C"); + static_assert((!std::is_base_of::value), "C is not a base of A"); + static_assert((std::is_base_of::value), "A is a base of F"); + static_assert((!std::is_base_of::value), "F is not a base of A"); + static_assert((!std::is_base_of::value), "A is not a base of D"); + static_assert((!std::is_base_of::value), "D is not a base of A"); + static_assert((std::is_base_of::value), "B is the same as B (and therefore, a base of B)"); } diff --git a/widget/android/jni/Natives.h b/widget/android/jni/Natives.h index e4a6bf262ccd..5bafd1b0b4cc 100644 --- a/widget/android/jni/Natives.h +++ b/widget/android/jni/Natives.h @@ -128,7 +128,7 @@ enum NativePtrType { OWNING, WEAK, REFPTR }; template class NativePtrPicker { template - static typename EnableIf, I>::value, + static typename EnableIf, I>::value, char (&)[NativePtrType::WEAK]>::Type Test(char); diff --git a/widget/android/nsAppShell.h b/widget/android/nsAppShell.h index b1e781e149d7..2478d781f4c9 100644 --- a/widget/android/nsAppShell.h +++ b/widget/android/nsAppShell.h @@ -131,9 +131,9 @@ class nsAppShell : public nsBaseAppShell { const mozilla::TimeDuration timeout = mozilla::TimeDuration::Forever()); template - static typename mozilla::EnableIf::value, - void>::Type - SyncRunEvent(T&& lambda) { + static + typename mozilla::EnableIf::value, void>::Type + SyncRunEvent(T&& lambda) { SyncRunEvent(LambdaEvent(std::forward(lambda))); } diff --git a/xpcom/base/HoldDropJSObjects.h b/xpcom/base/HoldDropJSObjects.h index 1a2c5cb75779..31c892d2527c 100644 --- a/xpcom/base/HoldDropJSObjects.h +++ b/xpcom/base/HoldDropJSObjects.h @@ -25,7 +25,7 @@ void DropJSObjectsImpl(nsISupports* aHolder); } // namespace cyclecollector -template ::value> +template ::value> struct HoldDropJSObjectsHelper { static void Hold(T* aHolder) { cyclecollector::HoldJSObjectsImpl(aHolder, diff --git a/xpcom/base/nsCOMPtr.h b/xpcom/base/nsCOMPtr.h index 63906f94ade2..268a351fcf0e 100644 --- a/xpcom/base/nsCOMPtr.h +++ b/xpcom/base/nsCOMPtr.h @@ -485,8 +485,7 @@ class MOZ_IS_REFPTR nsCOMPtr final MOZ_IMPLICIT nsCOMPtr(const nsCOMPtr& aSmartPtr) : NSCAP_CTOR_BASE(aSmartPtr.get()) { // Make sure that U actually inherits from T - static_assert(mozilla::IsBaseOf::value, - "U should be a subclass of T"); + static_assert(std::is_base_of::value, "U should be a subclass of T"); assert_validity(); if (mRawPtr) { NSCAP_ADDREF(this, mRawPtr); @@ -504,8 +503,7 @@ class MOZ_IS_REFPTR nsCOMPtr final MOZ_IMPLICIT nsCOMPtr(nsCOMPtr&& aSmartPtr) : NSCAP_CTOR_BASE(aSmartPtr.forget().template downcast().take()) { // Make sure that U actually inherits from T - static_assert(mozilla::IsBaseOf::value, - "U should be a subclass of T"); + static_assert(std::is_base_of::value, "U should be a subclass of T"); assert_validity(); NSCAP_LOG_ASSIGNMENT(this, mRawPtr); NSCAP_ASSERT_NO_QUERY_NEEDED(); @@ -541,7 +539,7 @@ class MOZ_IS_REFPTR nsCOMPtr final : NSCAP_CTOR_BASE(static_cast(aSmartPtr.take())) { assert_validity(); // But make sure that U actually inherits from T. - static_assert(mozilla::IsBaseOf::value, "U is not a subclass of T"); + static_assert(std::is_base_of::value, "U is not a subclass of T"); NSCAP_LOG_ASSIGNMENT(this, static_cast(mRawPtr)); NSCAP_ASSERT_NO_QUERY_NEEDED(); } @@ -552,7 +550,7 @@ class MOZ_IS_REFPTR nsCOMPtr final : NSCAP_CTOR_BASE(static_cast(aSmartPtr.take())) { assert_validity(); // But make sure that U actually inherits from T. - static_assert(mozilla::IsBaseOf::value, "U is not a subclass of T"); + static_assert(std::is_base_of::value, "U is not a subclass of T"); NSCAP_LOG_ASSIGNMENT(this, static_cast(mRawPtr)); NSCAP_ASSERT_NO_QUERY_NEEDED(); } @@ -647,8 +645,7 @@ class MOZ_IS_REFPTR nsCOMPtr final template nsCOMPtr& operator=(const nsCOMPtr& aRhs) { // Make sure that U actually inherits from T - static_assert(mozilla::IsBaseOf::value, - "U should be a subclass of T"); + static_assert(std::is_base_of::value, "U should be a subclass of T"); assign_with_AddRef(ToSupports(static_cast(aRhs.get()))); return *this; } @@ -661,8 +658,7 @@ class MOZ_IS_REFPTR nsCOMPtr final template nsCOMPtr& operator=(nsCOMPtr&& aRhs) { // Make sure that U actually inherits from T - static_assert(mozilla::IsBaseOf::value, - "U should be a subclass of T"); + static_assert(std::is_base_of::value, "U should be a subclass of T"); assign_assuming_AddRef(aRhs.forget().template downcast().take()); NSCAP_ASSERT_NO_QUERY_NEEDED(); return *this; @@ -683,7 +679,7 @@ class MOZ_IS_REFPTR nsCOMPtr final template nsCOMPtr& operator=(already_AddRefed& aRhs) { // Make sure that U actually inherits from T - static_assert(mozilla::IsBaseOf::value, "U is not a subclass of T"); + static_assert(std::is_base_of::value, "U is not a subclass of T"); assign_assuming_AddRef(static_cast(aRhs.take())); NSCAP_ASSERT_NO_QUERY_NEEDED(); return *this; @@ -693,7 +689,7 @@ class MOZ_IS_REFPTR nsCOMPtr final template nsCOMPtr& operator=(already_AddRefed&& aRhs) { // Make sure that U actually inherits from T - static_assert(mozilla::IsBaseOf::value, "U is not a subclass of T"); + static_assert(std::is_base_of::value, "U is not a subclass of T"); assign_assuming_AddRef(static_cast(aRhs.take())); NSCAP_ASSERT_NO_QUERY_NEEDED(); return *this; @@ -1156,7 +1152,7 @@ template void nsCOMPtr::assign_from_qi(const nsQueryInterface aQI, const nsIID& aIID) { static_assert( - !(mozilla::IsSame::value || mozilla::IsBaseOf::value), + !(mozilla::IsSame::value || std::is_base_of::value), "don't use do_QueryInterface for compile-time-determinable casts"); void* newRawPtr; if (NS_FAILED(aQI(aIID, &newRawPtr))) { @@ -1170,7 +1166,7 @@ template void nsCOMPtr::assign_from_qi_with_error( const nsQueryInterfaceWithError& aQI, const nsIID& aIID) { static_assert( - !(mozilla::IsSame::value || mozilla::IsBaseOf::value), + !(mozilla::IsSame::value || std::is_base_of::value), "don't use do_QueryInterface for compile-time-determinable casts"); void* newRawPtr; if (NS_FAILED(aQI(aIID, &newRawPtr))) { diff --git a/xpcom/base/nsCycleCollectionNoteChild.h b/xpcom/base/nsCycleCollectionNoteChild.h index 26da1c82e476..ba4d1cf2d8b1 100644 --- a/xpcom/base/nsCycleCollectionNoteChild.h +++ b/xpcom/base/nsCycleCollectionNoteChild.h @@ -48,7 +48,7 @@ nsISupports* ToSupports( // The default implementation of this class template is empty, because it // should never be used: see the partial specializations below. -template ::value> +template ::value> struct CycleCollectionNoteChildImpl {}; template diff --git a/xpcom/base/nsCycleCollectionParticipant.h b/xpcom/base/nsCycleCollectionParticipant.h index 3731c15c442f..9152b1cfbc7c 100644 --- a/xpcom/base/nsCycleCollectionParticipant.h +++ b/xpcom/base/nsCycleCollectionParticipant.h @@ -347,7 +347,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCOMCycleCollectionParticipant, // The default implementation of this class template is empty, because it // should never be used: see the partial specializations below. -template ::value> +template ::value> struct DowncastCCParticipantImpl {}; // Specialization for XPCOM CC participants diff --git a/xpcom/base/nsISupportsImpl.h b/xpcom/base/nsISupportsImpl.h index e915522ef26b..9b70eaeb8a8e 100644 --- a/xpcom/base/nsISupportsImpl.h +++ b/xpcom/base/nsISupportsImpl.h @@ -95,7 +95,7 @@ class nsAutoOwningThread { "Token '" #_type "' is not a class type.") # define MOZ_ASSERT_NOT_ISUPPORTS(_type) \ - static_assert(!mozilla::IsBaseOf::value, \ + static_assert(!std::is_base_of::value, \ "nsISupports classes don't need to call MOZ_COUNT_CTOR or " \ "MOZ_COUNT_DTOR"); diff --git a/xpcom/base/nsISupportsUtils.h b/xpcom/base/nsISupportsUtils.h index 481e016844bd..5b835a7ad47f 100644 --- a/xpcom/base/nsISupportsUtils.h +++ b/xpcom/base/nsISupportsUtils.h @@ -120,7 +120,7 @@ inline nsresult CallQueryInterface(T* aSource, DestinationType** aDestination) { // the canonical nsISupports pointer with CallQueryInterface. static_assert( !(mozilla::IsSame::value || - mozilla::IsBaseOf::value) || + std::is_base_of::value) || mozilla::IsSame::value, "don't use CallQueryInterface for compile-time-determinable casts"); diff --git a/xpcom/components/ModuleUtils.h b/xpcom/components/ModuleUtils.h index 2dc572cef09d..ef3af42d849a 100644 --- a/xpcom/components/ModuleUtils.h +++ b/xpcom/components/ModuleUtils.h @@ -78,7 +78,7 @@ struct RemoveAlreadyAddRefed> { mozilla::IsSame, decltype(_GetterProc())>::value, \ "Singleton constructor must return already_AddRefed"); \ static_assert( \ - mozilla::IsBaseOf<_InstanceClass, T>::value, \ + std::is_base_of<_InstanceClass, T>::value, \ "Singleton constructor must return correct already_AddRefed"); \ inst = _GetterProc(); \ if (nullptr == inst) { \ diff --git a/xpcom/components/gen_static_components.py b/xpcom/components/gen_static_components.py index b120c4ff3f18..d892bee9a7de 100644 --- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -360,7 +360,7 @@ class ModuleEntry(object): mozilla::IsSame, decltype(%(constructor)s())>::value, "Singleton constructor must return already_AddRefed"); static_assert( - mozilla::IsBaseOf<%(type)s, T>::value, + std::is_base_of<%(type)s, T>::value, "Singleton constructor must return correct already_AddRefed"); """ % {'type': self.type, 'constructor': self.constructor} diff --git a/xpcom/threads/ThreadEventQueue.cpp b/xpcom/threads/ThreadEventQueue.cpp index 43981f73259e..4f167246a707 100644 --- a/xpcom/threads/ThreadEventQueue.cpp +++ b/xpcom/threads/ThreadEventQueue.cpp @@ -50,7 +50,7 @@ ThreadEventQueue::ThreadEventQueue(UniquePtr aQueue) : mBaseQueue(std::move(aQueue)), mLock("ThreadEventQueue"), mEventsAvailable(mLock, "EventsAvail") { - static_assert(IsBaseOf::value, + static_assert(std::is_base_of::value, "InnerQueueT must be an AbstractEventQueue subclass"); } diff --git a/xpcom/threads/nsProxyRelease.h b/xpcom/threads/nsProxyRelease.h index c1b84b645100..05d54767bd6c 100644 --- a/xpcom/threads/nsProxyRelease.h +++ b/xpcom/threads/nsProxyRelease.h @@ -127,8 +127,10 @@ template inline NS_HIDDEN_(void) NS_ProxyRelease(const char* aName, nsIEventTarget* aTarget, already_AddRefed aDoomed, bool aAlwaysProxy = false) { - ::detail::ProxyReleaseChooser::value>:: - ProxyRelease(aName, aTarget, std::move(aDoomed), aAlwaysProxy); + ::detail::ProxyReleaseChooser< + std::is_base_of::value>::ProxyRelease(aName, aTarget, + std::move(aDoomed), + aAlwaysProxy); } /** diff --git a/xpcom/threads/nsThreadUtils.h b/xpcom/threads/nsThreadUtils.h index 0b66cccd149c..43f82ae67830 100644 --- a/xpcom/threads/nsThreadUtils.h +++ b/xpcom/threads/nsThreadUtils.h @@ -810,7 +810,7 @@ template struct nsRunnableMethodTraits { typedef typename mozilla::RemoveRawOrSmartPointer::Type class_type; - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Stored class must inherit from method's class"); typedef R return_type; typedef nsRunnableMethod base_type; @@ -822,7 +822,7 @@ template { typedef const typename mozilla::RemoveRawOrSmartPointer::Type class_type; - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Stored class must inherit from method's class"); typedef R return_type; typedef nsRunnableMethod base_type; @@ -835,7 +835,7 @@ template { typedef typename mozilla::RemoveRawOrSmartPointer::Type class_type; - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Stored class must inherit from method's class"); typedef R return_type; typedef nsRunnableMethod base_type; @@ -846,7 +846,7 @@ template struct nsRunnableMethodTraits { typedef typename mozilla::RemoveRawOrSmartPointer::Type class_type; - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Stored class must inherit from method's class"); typedef R return_type; typedef nsRunnableMethod base_type; @@ -859,7 +859,7 @@ struct nsRunnableMethodTraits { typedef const typename mozilla::RemoveRawOrSmartPointer::Type class_type; - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Stored class must inherit from method's class"); typedef R return_type; typedef nsRunnableMethod base_type; @@ -872,7 +872,7 @@ struct nsRunnableMethodTraits { typedef const typename mozilla::RemoveRawOrSmartPointer::Type class_type; - static_assert(mozilla::IsBaseOf::value, + static_assert(std::is_base_of::value, "Stored class must inherit from method's class"); typedef R return_type; typedef nsRunnableMethod base_type;