Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
base::internal::CheckedSubOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type > Struct Template Reference

#include <checked_math_impl.h>

Public Types

using result_type = typename MaxExponentPromotion< T, U >::type
 

Static Public Member Functions

template<typename V >
static constexpr bool Do (T x, U y, V *result)
 

Detailed Description

template<typename T, typename U>
struct base::internal::CheckedSubOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >

Definition at line 104 of file checked_math_impl.h.

Member Typedef Documentation

◆ result_type

template<typename T , typename U >
using base::internal::CheckedSubOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >::result_type = typename MaxExponentPromotion<T, U>::type

Definition at line 108 of file checked_math_impl.h.

Member Function Documentation

◆ Do()

template<typename T , typename U >
template<typename V >
static constexpr bool base::internal::CheckedSubOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >::Do ( T  x,
y,
V result 
)
inlinestaticconstexpr

Definition at line 110 of file checked_math_impl.h.

110 {
111 // TODO(jschuh) Make this "constexpr if" once we're C++17.
114
115 // Double the underlying type up to a full machine word.
116 using FastPromotion = typename FastIntegerArithmeticPromotion<T, U>::type;
117 using Promotion =
118 typename std::conditional<(IntegerBitsPlusSign<FastPromotion>::value >
120 typename BigEnoughPromotion<T, U>::type,
121 FastPromotion>::type;
122 // Fail if either operand is out of range for the promoted type.
123 // TODO(jschuh): This could be made to work for a broader range of values.
124 if (BASE_NUMERICS_UNLIKELY(!IsValueInRangeForNumericType<Promotion>(x) ||
125 !IsValueInRangeForNumericType<Promotion>(y))) {
126 return false;
127 }
128
129 Promotion presult = {};
130 bool is_valid = true;
132 presult = static_cast<Promotion>(x) - static_cast<Promotion>(y);
133 } else {
134 is_valid = CheckedSubImpl(static_cast<Promotion>(x),
135 static_cast<Promotion>(y), &presult);
136 }
137 *result = static_cast<V>(presult);
138 return is_valid && IsValueInRangeForNumericType<V>(presult);
139 }
static bool is_valid(SkISize dim)
GAsyncResult * result
T __attribute__((ext_vector_type(N))) V
double y
double x
constexpr bool CheckedSubImpl(T x, T y, T *result)
#define BASE_NUMERICS_UNLIKELY(x)
static constexpr bool Do(T, U, V *)

The documentation for this struct was generated from the following file: