diff options
-rw-r--r-- | include/gpu/GrBlend.h | 56 | ||||
-rw-r--r-- | include/private/SkTLogic.h | 197 | ||||
-rw-r--r-- | include/private/SkTemplates.h | 16 | ||||
-rw-r--r-- | src/core/SkRecord.h | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrPorterDuffXferProcessor.cpp | 2 | ||||
-rw-r--r-- | src/utils/SkTFitsIn.h | 52 |
6 files changed, 162 insertions, 165 deletions
diff --git a/include/gpu/GrBlend.h b/include/gpu/GrBlend.h index 52a0300ee4..51c19f9721 100644 --- a/include/gpu/GrBlend.h +++ b/include/gpu/GrBlend.h @@ -75,10 +75,10 @@ static const int kGrBlendCoeffCnt = kLast_GrBlendCoeff + 1; template<GrBlendCoeff Coeff> -struct GrTBlendCoeffRefsSrc : SkTBool<kSC_GrBlendCoeff == Coeff || - kISC_GrBlendCoeff == Coeff || - kSA_GrBlendCoeff == Coeff || - kISA_GrBlendCoeff == Coeff> {}; +struct GrTBlendCoeffRefsSrc : skstd::bool_constant<kSC_GrBlendCoeff == Coeff || + kISC_GrBlendCoeff == Coeff || + kSA_GrBlendCoeff == Coeff || + kISA_GrBlendCoeff == Coeff> {}; #define GR_BLEND_COEFF_REFS_SRC(COEFF) \ GrTBlendCoeffRefsSrc<COEFF>::value @@ -97,10 +97,10 @@ inline bool GrBlendCoeffRefsSrc(GrBlendCoeff coeff) { template<GrBlendCoeff Coeff> -struct GrTBlendCoeffRefsDst : SkTBool<kDC_GrBlendCoeff == Coeff || - kIDC_GrBlendCoeff == Coeff || - kDA_GrBlendCoeff == Coeff || - kIDA_GrBlendCoeff == Coeff> {}; +struct GrTBlendCoeffRefsDst : skstd::bool_constant<kDC_GrBlendCoeff == Coeff || + kIDC_GrBlendCoeff == Coeff || + kDA_GrBlendCoeff == Coeff || + kIDA_GrBlendCoeff == Coeff> {}; #define GR_BLEND_COEFF_REFS_DST(COEFF) \ GrTBlendCoeffRefsDst<COEFF>::value @@ -119,10 +119,10 @@ inline bool GrBlendCoeffRefsDst(GrBlendCoeff coeff) { template<GrBlendCoeff Coeff> -struct GrTBlendCoeffRefsSrc2 : SkTBool<kS2C_GrBlendCoeff == Coeff || - kIS2C_GrBlendCoeff == Coeff || - kS2A_GrBlendCoeff == Coeff || - kIS2A_GrBlendCoeff == Coeff> {}; +struct GrTBlendCoeffRefsSrc2 : skstd::bool_constant<kS2C_GrBlendCoeff == Coeff || + kIS2C_GrBlendCoeff == Coeff || + kS2A_GrBlendCoeff == Coeff || + kIS2A_GrBlendCoeff == Coeff> {}; #define GR_BLEND_COEFF_REFS_SRC2(COEFF) \ GrTBlendCoeffRefsSrc2<COEFF>::value @@ -141,23 +141,23 @@ inline bool GrBlendCoeffRefsSrc2(GrBlendCoeff coeff) { template<GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> -struct GrTBlendCoeffsUseSrcColor : SkTBool<kZero_GrBlendCoeff != SrcCoeff || - GR_BLEND_COEFF_REFS_SRC(DstCoeff)> {}; +struct GrTBlendCoeffsUseSrcColor : skstd::bool_constant<kZero_GrBlendCoeff != SrcCoeff || + GR_BLEND_COEFF_REFS_SRC(DstCoeff)> {}; #define GR_BLEND_COEFFS_USE_SRC_COLOR(SRC_COEFF, DST_COEFF) \ GrTBlendCoeffsUseSrcColor<SRC_COEFF, DST_COEFF>::value template<GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> -struct GrTBlendCoeffsUseDstColor : SkTBool<GR_BLEND_COEFF_REFS_DST(SrcCoeff) || - kZero_GrBlendCoeff != DstCoeff> {}; +struct GrTBlendCoeffsUseDstColor : skstd::bool_constant<GR_BLEND_COEFF_REFS_DST(SrcCoeff) || + kZero_GrBlendCoeff != DstCoeff> {}; #define GR_BLEND_COEFFS_USE_DST_COLOR(SRC_COEFF, DST_COEFF) \ GrTBlendCoeffsUseDstColor<SRC_COEFF, DST_COEFF>::value template<GrBlendEquation Equation> -struct GrTBlendEquationIsAdvanced : SkTBool<Equation >= kFirstAdvancedGrBlendEquation> {}; +struct GrTBlendEquationIsAdvanced : skstd::bool_constant<Equation >= kFirstAdvancedGrBlendEquation> {}; #define GR_BLEND_EQUATION_IS_ADVANCED(EQUATION) \ GrTBlendEquationIsAdvanced<EQUATION>::value @@ -168,10 +168,10 @@ inline bool GrBlendEquationIsAdvanced(GrBlendEquation equation) { template<GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> -struct GrTBlendModifiesDst : SkTBool<(kAdd_GrBlendEquation != BlendEquation && - kReverseSubtract_GrBlendEquation != BlendEquation) || - kZero_GrBlendCoeff != SrcCoeff || - kOne_GrBlendCoeff != DstCoeff> {}; +struct GrTBlendModifiesDst : skstd::bool_constant< + (kAdd_GrBlendEquation != BlendEquation && kReverseSubtract_GrBlendEquation != BlendEquation) || + kZero_GrBlendCoeff != SrcCoeff || + kOne_GrBlendCoeff != DstCoeff> {}; #define GR_BLEND_MODIFIES_DST(EQUATION, SRC_COEFF, DST_COEFF) \ GrTBlendModifiesDst<EQUATION, SRC_COEFF, DST_COEFF>::value @@ -202,13 +202,13 @@ struct GrTBlendModifiesDst : SkTBool<(kAdd_GrBlendEquation != BlendEquation && * dstCoeff references S. */ template<GrBlendEquation Equation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> -struct GrTBlendCanTweakAlphaForCoverage : SkTBool<GR_BLEND_EQUATION_IS_ADVANCED(Equation) || - ((kAdd_GrBlendEquation == Equation || - kReverseSubtract_GrBlendEquation == Equation) && - !GR_BLEND_COEFF_REFS_SRC(SrcCoeff) && - (kOne_GrBlendCoeff == DstCoeff || - kISC_GrBlendCoeff == DstCoeff || - kISA_GrBlendCoeff == DstCoeff))> {}; +struct GrTBlendCanTweakAlphaForCoverage : skstd::bool_constant< + GR_BLEND_EQUATION_IS_ADVANCED(Equation) || + ((kAdd_GrBlendEquation == Equation || kReverseSubtract_GrBlendEquation == Equation) && + !GR_BLEND_COEFF_REFS_SRC(SrcCoeff) && + (kOne_GrBlendCoeff == DstCoeff || + kISC_GrBlendCoeff == DstCoeff || + kISA_GrBlendCoeff == DstCoeff))> {}; #define GR_BLEND_CAN_TWEAK_ALPHA_FOR_COVERAGE(EQUATION, SRC_COEFF, DST_COEFF) \ GrTBlendCanTweakAlphaForCoverage<EQUATION, SRC_COEFF, DST_COEFF>::value diff --git a/include/private/SkTLogic.h b/include/private/SkTLogic.h index f93f63b1a2..0a71d704dc 100644 --- a/include/private/SkTLogic.h +++ b/include/private/SkTLogic.h @@ -8,11 +8,6 @@ * This header provides some of the helpers (std::integral_constant) and * type transformations (std::conditional) which will become available with * C++11 in the type_traits header. - * - * Because we lack constexpr, we cannot mimic - * std::integral_constant::'constexpr operator T()'. - * As a result we introduce SkTBool and SkTIf similar to Boost in order to - * minimize the visual noise of many uses of '::value'. */ #ifndef SkTLogic_DEFINED @@ -20,71 +15,125 @@ #include <stdint.h> -/** Represents a templated integer constant. - * Pre-C++11 version of std::integral_constant. - */ -template <typename T, T v> struct SkTIntegralConstant { - static const T value = v; - typedef T value_type; - typedef SkTIntegralConstant<T, v> type; +namespace skstd { + +template <typename T, T v> struct integral_constant { + static const/*expr*/ T value = v; + using value_type = T; + using type = integral_constant<T, v>; + //constexpr operator value_type() const noexcept { return value; } + //constexpr value_type operator()() const noexcept { return value; } }; -/** Convenience specialization of SkTIntegralConstant. */ -template <bool b> struct SkTBool : SkTIntegralConstant<bool, b> { }; +template <bool B> using bool_constant = integral_constant<bool, B>; + +using true_type = bool_constant<true>; +using false_type = bool_constant<false>; + +template <bool B, typename T, typename F> struct conditional { using type = T; }; +template <typename T, typename F> struct conditional<false, T, F> { using type = F; }; +template <bool B, typename T, typename F> using conditional_t = typename conditional<B, T, F>::type; + +template <bool B, typename T = void> struct enable_if { using type = T; }; +template <typename T> struct enable_if<false, T> {}; +template <bool B, typename T = void> using enable_if_t = typename enable_if<B, T>::type; + +template <typename T> struct remove_const { using type = T; }; +template <typename T> struct remove_const<const T> { using type = T; }; +template <typename T> using remove_const_t = typename remove_const<T>::type; + +template <typename T> struct remove_volatile { using type = T; }; +template <typename T> struct remove_volatile<volatile T> { using type = T; }; +template <typename T> using remove_volatile_t = typename remove_volatile<T>::type; + +template <typename T> struct remove_cv { using type = remove_volatile_t<remove_const_t<T>>; }; +template <typename T> using remove_cv_t = typename remove_cv<T>::type; + +template <typename T> struct remove_reference { using type = T; }; +template <typename T> struct remove_reference<T&> { using type = T; }; +template <typename T> struct remove_reference<T&&> { using type = T; }; +template <typename T> using remove_reference_t = typename remove_reference<T>::type; + +template <typename T, typename U> struct is_same : false_type {}; +template <typename T> struct is_same<T, T> : true_type {}; + +template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {}; + +template <typename T> struct is_const : false_type {}; +template <typename T> struct is_const<const T> : true_type {}; -/** Pre-C++11 version of std::is_empty<T>. */ -template <typename T> -class SkTIsEmpty { - struct Derived : public T { char unused; }; -public: +template <typename T> struct is_volatile : false_type {}; +template <typename T> struct is_volatile<volatile T> : true_type {}; + +template <typename T> struct is_reference : false_type {}; +template <typename T> struct is_reference<T&> : true_type {}; +template <typename T> struct is_reference<T&&> : true_type {}; + +template <typename T> struct is_lvalue_reference : false_type {}; +template <typename T> struct is_lvalue_reference<T&> : true_type {}; + +template <typename T> struct is_empty_detector { + struct Derived : public remove_cv_t<T> { char unused; }; static const bool value = sizeof(Derived) == sizeof(char); }; +template <typename T> struct is_empty : bool_constant<is_empty_detector<T>::value> {}; -/** Pre-C++11 version of std::true_type. */ -typedef SkTBool<true> SkTrue; +template <typename T> struct add_const { using type = const T; }; +template <typename T> using add_const_t = typename add_const<T>::type; -/** Pre-C++11 version of std::false_type. */ -typedef SkTBool<false> SkFalse; +template <typename T> struct add_volatile { using type = volatile T; }; +template <typename T> using add_volatile_t = typename add_volatile<T>::type; -/** SkTIf_c::type = (condition) ? T : F; - * Pre-C++11 version of std::conditional. - */ -template <bool condition, typename T, typename F> struct SkTIf_c { - typedef F type; -}; -template <typename T, typename F> struct SkTIf_c<true, T, F> { - typedef T type; +template <typename T> struct add_cv { using type = add_volatile_t<add_const_t<T>>; }; +template <typename T> using add_cv_t = typename add_cv<T>::type; + +template <typename T> struct add_rvalue_reference { + using type = conditional_t<is_void<T>::value || is_reference<T>::value, T, T&&>; }; +template <typename T> using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; -/** SkTIf::type = (Condition::value) ? T : F; */ -template <typename Condition, typename T, typename F> struct SkTIf { - typedef typename SkTIf_c<static_cast<bool>(Condition::value), T, F>::type type; +} // namespace skstd + +// The sknonstd namespace contains things we would like to be proposed and feel std-ish. +namespace sknonstd { + +// The name 'copy' here is fraught with peril. In this case it means 'append', not 'overwrite'. +// Alternate proposed names are 'propagate', 'augment', or 'append' (and 'add', but already taken). +// std::experimental::propagate_const already exists for other purposes in TSv2. +// These also follow the <dest, source> pattern used by boost. +template <typename D, typename S> struct copy_const { + using type = skstd::conditional_t<skstd::is_const<S>::value, skstd::add_const_t<D>, D>; }; +template <typename D, typename S> using copy_const_t = typename copy_const<D, S>::type; -/** SkTMux::type = (a && b) ? Both : (a) ? A : (b) ? B : Neither; */ -template <typename a, typename b, typename Both, typename A, typename B, typename Neither> -struct SkTMux { - typedef typename SkTIf<a, typename SkTIf<b, Both, A>::type, - typename SkTIf<b, B, Neither>::type>::type type; +template <typename D, typename S> struct copy_volatile { + using type = skstd::conditional_t<skstd::is_volatile<S>::value, skstd::add_volatile_t<D>, D>; }; +template <typename D, typename S> using copy_volatile_t = typename copy_volatile<D, S>::type; -/** SkTEnableIf_c::type = (condition) ? T : [does not exist]; */ -template <bool condition, class T = void> struct SkTEnableIf_c { }; -template <class T> struct SkTEnableIf_c<true, T> { - typedef T type; +template <typename D, typename S> struct copy_cv { + using type = copy_volatile_t<copy_const_t<D, S>, S>; }; +template <typename D, typename S> using copy_cv_t = typename copy_cv<D, S>::type; + +// The name 'same' here means 'overwrite'. +// Alternate proposed names are 'replace', 'transfer', or 'qualify_from'. +// same_xxx<D, S> can be written as copy_xxx<remove_xxx_t<D>, S> +template <typename D, typename S> using same_const = copy_const<skstd::remove_const_t<D>, S>; +template <typename D, typename S> using same_const_t = typename same_const<D, S>::type; +template <typename D, typename S> using same_volatile =copy_volatile<skstd::remove_volatile_t<D>,S>; +template <typename D, typename S> using same_volatile_t = typename same_volatile<D, S>::type; +template <typename D, typename S> using same_cv = copy_cv<skstd::remove_cv_t<D>, S>; +template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type; -/** SkTEnableIf::type = (Condition::value) ? T : [does not exist]; */ -template <class Condition, class T = void> struct SkTEnableIf - : public SkTEnableIf_c<static_cast<bool>(Condition::value), T> { }; +} // namespace sknonstd /** Use as a return type to enable a function only when cond_type::value is true, * like C++14's std::enable_if_t. E.g. (N.B. this is a dumb example.) - * SK_WHEN(SkTrue, int) f(void* ptr) { return 1; } - * SK_WHEN(!SkTrue, int) f(void* ptr) { return 2; } + * SK_WHEN(true_type, int) f(void* ptr) { return 1; } + * SK_WHEN(!true_type, int) f(void* ptr) { return 2; } */ -#define SK_WHEN(cond_prefix, T) typename SkTEnableIf_c<cond_prefix::value, T>::type -#define SK_WHEN_C(cond, T) typename SkTEnableIf_c<cond, T>::type +#define SK_WHEN(cond_prefix, T) skstd::enable_if_t<cond_prefix::value, T> // See http://en.wikibooks.org/wiki/More_C++_Idioms/Member_Detector #define SK_CREATE_MEMBER_DETECTOR(member) \ @@ -110,52 +159,4 @@ public: \ static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \ } -namespace skstd { - -template <typename T> struct remove_const { using type = T; }; -template <typename T> struct remove_const<const T> { using type = T; }; -template <typename T> using remove_const_t = typename remove_const<T>::type; - -template <typename T> struct remove_volatile { using type = T; }; -template <typename T> struct remove_volatile<volatile T> { using type = T; }; -template <typename T> using remove_volatile_t = typename remove_volatile<T>::type; - -template <typename T> struct remove_cv { using type = remove_volatile_t<remove_const_t<T>>; }; -template <typename T> using remove_cv_t = typename remove_cv<T>::type; - -template <typename T> struct remove_reference { using type = T; }; -template <typename T> struct remove_reference<T&> { using type = T; }; -template <typename T> struct remove_reference<T&&> { using type = T; }; -template <typename T> using remove_reference_t = typename remove_reference<T>::type; - -template <typename T, typename U> struct is_same : SkFalse {}; -template <typename T> struct is_same<T, T> : SkTrue {}; - -template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {}; - -template <typename T> struct is_reference : SkFalse {}; -template <typename T> struct is_reference<T&> : SkTrue {}; -template <typename T> struct is_reference<T&&> : SkTrue {}; - -template <typename T> struct is_lvalue_reference : SkFalse {}; -template <typename T> struct is_lvalue_reference<T&> : SkTrue {}; - -template <typename T> struct add_rvalue_reference { - using type = typename SkTIf_c<is_void<T>::value || is_reference<T>::value, T, T&&>::type; -}; -template <typename T> using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; - -} // namespace skstd - -/** - * SkTIsConst<T>::value is true if the type T is const. - * The type T is constrained not to be an array or reference type. - */ -template <typename T> struct SkTIsConst { - static T* t; - static uint16_t test(const volatile void*); - static uint32_t test(volatile void *); - static const bool value = (sizeof(uint16_t) == sizeof(test(t))); -}; - #endif diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h index 1cbc4f1275..023bba379c 100644 --- a/include/private/SkTemplates.h +++ b/include/private/SkTemplates.h @@ -47,16 +47,6 @@ template <typename T> add_rvalue_reference_t<T> declval(); } // namespace skstd -///@{ -/** SkTConstType<T, CONST>::type will be 'const T' if CONST is true, 'T' otherwise. */ -template <typename T, bool CONST> struct SkTConstType { - typedef T type; -}; -template <typename T> struct SkTConstType<T, true> { - typedef const T type; -}; -///@} - /** * Returns a pointer to a D which comes immediately after S[count]. */ @@ -68,11 +58,9 @@ template <typename D, typename S> static D* SkTAfter(S* ptr, size_t count = 1) { * Returns a pointer to a D which comes byteOffset bytes after S. */ template <typename D, typename S> static D* SkTAddOffset(S* ptr, size_t byteOffset) { - // The intermediate char* has the same const-ness as D as this produces better error messages. + // The intermediate char* has the same cv-ness as D as this produces better error messages. // This relies on the fact that reinterpret_cast can add constness, but cannot remove it. - return reinterpret_cast<D*>( - reinterpret_cast<typename SkTConstType<char, SkTIsConst<D>::value>::type*>(ptr) + byteOffset - ); + return reinterpret_cast<D*>(reinterpret_cast<sknonstd::same_cv_t<char, D>*>(ptr) + byteOffset); } /** \class SkAutoTCallVProc diff --git a/src/core/SkRecord.h b/src/core/SkRecord.h index 9672bbcffa..933cccceb8 100644 --- a/src/core/SkRecord.h +++ b/src/core/SkRecord.h @@ -134,13 +134,13 @@ private: }; template <typename T> - SK_WHEN(SkTIsEmpty<T>, T*) allocCommand() { + SK_WHEN(skstd::is_empty<T>, T*) allocCommand() { static T singleton = {}; return &singleton; } template <typename T> - SK_WHEN(!SkTIsEmpty<T>, T*) allocCommand() { return this->alloc<T>(); } + SK_WHEN(!skstd::is_empty<T>, T*) allocCommand() { return this->alloc<T>(); } void grow(); diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index ff857f4e0d..4c9af42cde 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -68,7 +68,7 @@ public: */ template<OutputType PrimaryOut, OutputType SecondaryOut, GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> - struct get_properties : SkTIntegralConstant<Properties, static_cast<Properties>( + struct get_properties : skstd::integral_constant<Properties, static_cast<Properties>( (GR_BLEND_MODIFIES_DST(BlendEquation, SrcCoeff, DstCoeff) ? kModifiesDst_Property : 0) | diff --git a/src/utils/SkTFitsIn.h b/src/utils/SkTFitsIn.h index bbc22d410d..cf92822d8f 100644 --- a/src/utils/SkTFitsIn.h +++ b/src/utils/SkTFitsIn.h @@ -15,16 +15,23 @@ namespace sktfitsin { namespace Private { -/** SkTHasMoreDigits::type = (digits(A) >= digits(B)) ? SkTrue : SkFalse. */ -template<typename A, typename B> struct SkTHasMoreDigits { - typedef SkTBool<std::numeric_limits<A>::digits >= std::numeric_limits<B>::digits> type; +/** SkTMux::type = (a && b) ? Both : (a) ? A : (b) ? B : Neither; */ +template <bool a, bool b, typename Both, typename A, typename B, typename Neither> +struct SkTMux { + using type = skstd::conditional_t<a, skstd::conditional_t<b, Both, A>, + skstd::conditional_t<b, B, Neither>>; }; +/** SkTHasMoreDigits = (digits(A) >= digits(B)) ? true_type : false_type. */ +template<typename A, typename B> struct SkTHasMoreDigits + : skstd::bool_constant<std::numeric_limits<A>::digits >= std::numeric_limits<B>::digits> +{ }; + /** A high or low side predicate which is used when it is statically known * that source values are in the range of the Destination. */ template <typename S> struct SkTOutOfRange_False { - typedef SkFalse can_be_true; + typedef skstd::false_type can_be_true; typedef S source_type; static bool apply(S s) { return false; @@ -35,10 +42,10 @@ template <typename S> struct SkTOutOfRange_False { * Assumes that Min(S) <= Min(D). */ template <typename D, typename S> struct SkTOutOfRange_LT_MinD { - typedef SkTrue can_be_true; + typedef skstd::true_type can_be_true; typedef S source_type; static bool apply(S s) { - typedef typename SkTHasMoreDigits<S, D>::type precondition; + typedef SkTHasMoreDigits<S, D> precondition; static_assert(precondition::value, "SkTOutOfRange_LT_MinD__minS_gt_minD"); return s < static_cast<S>((std::numeric_limits<D>::min)()); @@ -47,7 +54,7 @@ template <typename D, typename S> struct SkTOutOfRange_LT_MinD { /** A low side predicate which tests if the source value is less than 0. */ template <typename D, typename S> struct SkTOutOfRange_LT_Zero { - typedef SkTrue can_be_true; + typedef skstd::true_type can_be_true; typedef S source_type; static bool apply(S s) { return s < static_cast<S>(0); @@ -58,10 +65,10 @@ template <typename D, typename S> struct SkTOutOfRange_LT_Zero { * Assumes that Max(S) >= Max(D). */ template <typename D, typename S> struct SkTOutOfRange_GT_MaxD { - typedef SkTrue can_be_true; + typedef skstd::true_type can_be_true; typedef S source_type; static bool apply(S s) { - typedef typename SkTHasMoreDigits<S, D>::type precondition; + typedef SkTHasMoreDigits<S, D> precondition; static_assert(precondition::value, "SkTOutOfRange_GT_MaxD__maxS_lt_maxD"); return s > static_cast<S>((std::numeric_limits<D>::max)()); @@ -72,7 +79,7 @@ template <typename D, typename S> struct SkTOutOfRange_GT_MaxD { * First checks OutOfRange_Low then, if in range, OutOfRange_High. */ template<class OutOfRange_Low, class OutOfRange_High> struct SkTOutOfRange_Either { - typedef SkTrue can_be_true; + typedef skstd::true_type can_be_true; typedef typename OutOfRange_Low::source_type source_type; static bool apply(source_type s) { bool outOfRange = OutOfRange_Low::apply(s); @@ -93,7 +100,7 @@ template<class OutOfRange_Low, class OutOfRange_High> struct SkTCombineOutOfRang typedef typename OutOfRange_Low::can_be_true apply_low; typedef typename OutOfRange_High::can_be_true apply_high; - typedef typename SkTMux<apply_low, apply_high, + typedef typename SkTMux<apply_low::value, apply_high::value, Both, OutOfRange_Low, OutOfRange_High, Neither>::type type; }; @@ -119,8 +126,8 @@ template<typename D, typename S> struct SkTFitsIn_Unsigned2Unsiged { // If std::numeric_limits<D>::digits >= std::numeric_limits<S>::digits, nothing to check. // This also protects the precondition of SkTOutOfRange_GT_MaxD. - typedef typename SkTHasMoreDigits<D, S>::type sourceFitsInDesitination; - typedef typename SkTIf<sourceFitsInDesitination, NoCheck, HighSideOnlyCheck>::type type; + typedef SkTHasMoreDigits<D, S> sourceFitsInDesitination; + typedef skstd::conditional_t<sourceFitsInDesitination::value, NoCheck, HighSideOnlyCheck> type; }; /** SkTFitsIn_Signed2Signed::type is an SkTRangeChecker with an OutOfRange(S s) method @@ -136,8 +143,8 @@ template<typename D, typename S> struct SkTFitsIn_Signed2Signed { // If std::numeric_limits<D>::digits >= std::numeric_limits<S>::digits, nothing to check. // This also protects the precondition of SkTOutOfRange_LT_MinD and SkTOutOfRange_GT_MaxD. - typedef typename SkTHasMoreDigits<D, S>::type sourceFitsInDesitination; - typedef typename SkTIf<sourceFitsInDesitination, NoCheck, FullCheck>::type type; + typedef SkTHasMoreDigits<D, S> sourceFitsInDesitination; + typedef skstd::conditional_t<sourceFitsInDesitination::value, NoCheck, FullCheck> type; }; /** SkTFitsIn_Signed2Unsigned::type is an SkTRangeChecker with an OutOfRange(S s) method @@ -154,8 +161,8 @@ template<typename D, typename S> struct SkTFitsIn_Signed2Unsigned { // If std::numeric_limits<D>::max() >= std::numeric_limits<S>::max(), // no need to check the high side. (Until C++11, assume more digits means greater max.) // This also protects the precondition of SkTOutOfRange_GT_MaxD. - typedef typename SkTHasMoreDigits<D, S>::type sourceCannotExceedDesitination; - typedef typename SkTIf<sourceCannotExceedDesitination, LowSideOnlyCheck, FullCheck>::type type; + typedef SkTHasMoreDigits<D, S> sourceCannotExceedDest; + typedef skstd::conditional_t<sourceCannotExceedDest::value, LowSideOnlyCheck, FullCheck> type; }; /** SkTFitsIn_Unsigned2Signed::type is an SkTRangeChecker with an OutOfRange(S s) method @@ -172,8 +179,8 @@ template<typename D, typename S> struct SkTFitsIn_Unsigned2Signed { // If std::numeric_limits<D>::max() >= std::numeric_limits<S>::max(), nothing to check. // (Until C++11, assume more digits means greater max.) // This also protects the precondition of SkTOutOfRange_GT_MaxD. - typedef typename SkTHasMoreDigits<D, S>::type sourceCannotExceedDesitination; - typedef typename SkTIf<sourceCannotExceedDesitination, NoCheck, HighSideOnlyCheck>::type type; + typedef SkTHasMoreDigits<D, S> sourceCannotExceedDest; + typedef skstd::conditional_t<sourceCannotExceedDest::value, NoCheck, HighSideOnlyCheck> type; }; /** SkTFitsIn::type is an SkTRangeChecker with an OutOfRange(S s) method @@ -187,10 +194,11 @@ template<typename D, typename S> struct SkTFitsIn { typedef SkTFitsIn_Unsigned2Signed<D, S> U2S; typedef SkTFitsIn_Unsigned2Unsiged<D, S> U2U; - typedef SkTBool<std::numeric_limits<S>::is_signed> S_is_signed; - typedef SkTBool<std::numeric_limits<D>::is_signed> D_is_signed; + typedef skstd::bool_constant<std::numeric_limits<S>::is_signed> S_is_signed; + typedef skstd::bool_constant<std::numeric_limits<D>::is_signed> D_is_signed; - typedef typename SkTMux<S_is_signed, D_is_signed, S2S, S2U, U2S, U2U>::type selector; + typedef typename SkTMux<S_is_signed::value, D_is_signed::value, + S2S, S2U, U2S, U2U>::type selector; // This type is an SkTRangeChecker. typedef typename selector::type type; }; |