9#ifndef mozilla_TypeTraits_h
10#define mozilla_TypeTraits_h
26template<
typename>
struct RemoveCV;
34template<
typename T, T Value>
89#ifdef MOZ_CHAR16_IS_NOT_WCHAR
111template<
typename T,
typename U>
119 IsSame<T, float>::value ||
120 IsSame<T, double>::value ||
121 IsSame<T, long double>::value>
145template<
typename T, decltype(sizeof(1)) N>
296 IsLvalueReference<T>::value || IsRvalueReference<T>::value>
366#ifdef MOZ_CHAR16_IS_NOT_WCHAR
438template<
typename T,
typename NoCV>
442template<
typename T,
typename NoCV>
448template<typename T, typename NoCV>
449struct IsSignedHelper<T, false, false, NoCV> : FalseType {};
463struct IsSigned : detail::IsSignedHelper<T> {};
468 bool = IsFloatingPoint<T>::value,
469 bool = IsIntegral<T>::value,
470 typename NoCV = typename RemoveCV<T>::Type>
471struct IsUnsignedHelper;
474template<typename T, typename NoCV>
475struct IsUnsignedHelper<T, true, false, NoCV> : FalseType {};
478template<typename T, typename NoCV>
479struct IsUnsignedHelper<T, false, true, NoCV>
480 : IntegralConstant<bool,
481 (IsSame<NoCV, bool>::value || bool(NoCV(1) < NoCV(-1)))>
485template<typename T, typename NoCV>
486struct IsUnsignedHelper<T, false, false, NoCV> : FalseType {};
499struct IsUnsigned : detail::IsUnsignedHelper<T> {};
515template<typename T, typename U>
516struct IsSame : FalseType {};
519struct IsSame<T, T> : TrueType {};
523#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
525template<class Base, class Derived>
526struct BaseOfTester : IntegralConstant<bool, __is_base_of(Base, Derived)> {};
535template<class Base, class Derived>
539 operator Base*() const;
543template<class Base, class Derived>
548 static char test(Derived*, T);
549 static int test(Base*, int);
552 static const bool value =
553 sizeof(test(BaseOfHelper<Base, Derived>(), int())) == sizeof(char);
556template<class Base, class Derived>
557struct BaseOfTester<Base, const Derived>
561 static char test(Derived*, T);
562 static int test(Base*, int);
565 static const bool value =
566 sizeof(test(BaseOfHelper<Base, Derived>(), int())) == sizeof(char);
569template<class Base, class Derived>
570struct BaseOfTester<Base&, Derived&> : FalseType {};
573struct BaseOfTester<Type, Type> : TrueType {};
576struct BaseOfTester<Type, const Type> : TrueType {};
594template<class Base, class Derived>
596 : IntegralConstant<bool, detail::BaseOfTester<Base, Derived>::value>
601template<typename From, typename To>
602struct ConvertibleTester
605 static From create();
607 template<typename From1, typename To1>
608 static char test(To to);
610 template<typename From1, typename To1>
611 static int test(...);
614 static const bool value =
615 sizeof(test<From, To>(create())) == sizeof(char);
645template<typename From, typename To>
647 : IntegralConstant<bool, detail::ConvertibleTester<From, To>::value>
651struct IsConvertible<void, B>
652 : IntegralConstant<bool, IsVoid<B>::value>
656struct IsConvertible<A, void>
657 : IntegralConstant<bool, IsVoid<A>::value>
661struct IsConvertible<void, void>
684struct RemoveConst<const T>
704struct RemoveVolatile<volatile T>
720 typedef typename RemoveConst<typename RemoveVolatile<T>::Type>::Type Type;
734struct RemoveReference
740struct RemoveReference<T&>
746struct RemoveReference<T&&>
751template<bool Condition, typename A, typename B>
756enum Voidness { TIsVoid, TIsNotVoid };
758template<typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid>
759struct AddLvalueReferenceHelper;
762struct AddLvalueReferenceHelper<T, TIsVoid>
768struct AddLvalueReferenceHelper<T, TIsNotVoid>
790struct AddLvalueReference
791 : detail::AddLvalueReferenceHelper<T>
796template<typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid>
797struct AddRvalueReferenceHelper;
800struct AddRvalueReferenceHelper<T, TIsVoid>
806struct AddRvalueReferenceHelper<T, TIsNotVoid>
829struct AddRvalueReference
830 : detail::AddRvalueReferenceHelper<T>
842typename AddRvalueReference<T>::Type DeclVal();
846template<bool B, typename T = void>
851template<bool MakeConst, typename T>
852struct WithC : Conditional<MakeConst, const T, T>
855template<bool MakeVolatile, typename T>
856struct WithV : Conditional<MakeVolatile, volatile T, T>
860template<bool MakeConst, bool MakeVolatile, typename T>
861struct WithCV : WithC<MakeConst, typename WithV<MakeVolatile, T>::Type>
865struct CorrespondingSigned;
868struct CorrespondingSigned<char> { typedef signed char Type; };
870struct CorrespondingSigned<unsigned char> { typedef signed char Type; };
872struct CorrespondingSigned<unsigned short> { typedef short Type; };
874struct CorrespondingSigned<unsigned int> { typedef int Type; };
876struct CorrespondingSigned<unsigned long> { typedef long Type; };
878struct CorrespondingSigned<unsigned long long> { typedef long long Type; };
881 typename CVRemoved = typename RemoveCV<T>::Type,
882 bool IsSignedIntegerType = IsSigned<CVRemoved>::value &&
883 !IsSame<char, CVRemoved>::value>
886template<typename T, typename CVRemoved>
887struct MakeSigned<T, CVRemoved, true>
892template<typename T, typename CVRemoved>
893struct MakeSigned<T, CVRemoved, false>
894 : WithCV<IsConst<T>::value, IsVolatile<T>::value,
895 typename CorrespondingSigned<CVRemoved>::Type>
924 : EnableIf<IsIntegral<T>::value &&
925 !IsSame<bool, typename RemoveCV<T>::Type>::value,
926 typename detail::MakeSigned<T>
933struct CorrespondingUnsigned;
936struct CorrespondingUnsigned<char> { typedef unsigned char Type; };
938struct CorrespondingUnsigned<signed char> { typedef unsigned char Type; };
940struct CorrespondingUnsigned<short> { typedef unsigned short Type; };
942struct CorrespondingUnsigned<int> { typedef unsigned int Type; };
944struct CorrespondingUnsigned<long> { typedef unsigned long Type; };
946struct CorrespondingUnsigned<long long> { typedef unsigned long long Type; };
950 typename CVRemoved = typename RemoveCV<T>::Type,
951 bool IsUnsignedIntegerType = IsUnsigned<CVRemoved>::value &&
952 !IsSame<char, CVRemoved>::value>
955template<typename T, typename CVRemoved>
956struct MakeUnsigned<T, CVRemoved, true>
961template<typename T, typename CVRemoved>
962struct MakeUnsigned<T, CVRemoved, false>
963 : WithCV<IsConst<T>::value, IsVolatile<T>::value,
964 typename CorrespondingUnsigned<CVRemoved>::Type>
993 : EnableIf<IsIntegral<T>::value &&
994 !IsSame<bool, typename RemoveCV<T>::Type>::value,
995 typename detail::MakeUnsigned<T>
1017struct RemoveExtent<T[]>
1022template<typename T, decltype(sizeof(1)) N>
1023struct RemoveExtent<T[N]>
1032template<typename T, typename CVRemoved>
1033struct RemovePointerHelper
1038template<typename T, typename Pointee>
1039struct RemovePointerHelper<T, Pointee*>
1041 typedef Pointee Type;
1063 : detail::RemovePointerHelper<T, typename RemoveCV<T>::Type>
1086template<bool B, typename T>
1091struct EnableIf<true, T>
1102template<bool Condition, typename A, typename B>
1108template<class A, class B>
1109struct Conditional<false, A, B>
Compares two VersionParts.
IntegralConstant< bool, true > TrueType
Convenient aliases.
IntegralConstant< bool, false > FalseType
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
Helper class used as a base for various type traits, exposed publicly because <type_traits> exposes i...
IntegralConstant< T, Value > Type
IsArithmetic determines whether a type is arithmetic.
IsArray determines whether a type is an array type, of known or unknown length.
IsClass determines whether a type is a class type (but not a union).
IsConst determines whether a type is const or not.
IsEmpty determines whether a type is a class (but not a union) that is empty.
IsEnum determines whether a type is an enum type.
IsFloatingPoint determines whether a type is a floating point type (float, double,...
IsIntegral determines whether a type is an integral type.
IsLvalueReference determines whether a type is an lvalue reference.
Traits class for identifying POD types.
IsPointer determines whether a type is a possibly-CV-qualified pointer type (but not a pointer-to-mem...
IsReference determines whether a type is an lvalue or rvalue reference.
IsRvalueReference determines whether a type is an rvalue reference.
IsSame tests whether two types are the same type.
IsVoid determines whether a type is void.
IsVolatile determines whether a type is volatile or not.
RemoveConst< typenameRemoveVolatile< T >::Type >::Type Type