Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
base::internal::CheckedMulOp< 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::CheckedMulOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >

Definition at line 166 of file checked_math_impl.h.

Member Typedef Documentation

◆ result_type

template<typename T , typename U >
using base::internal::CheckedMulOp< 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 170 of file checked_math_impl.h.

Member Function Documentation

◆ Do()

template<typename T , typename U >
template<typename V >
static constexpr bool base::internal::CheckedMulOp< 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 172 of file checked_math_impl.h.

172 {
173 // TODO(jschuh) Make this "constexpr if" once we're C++17.
176
177 using Promotion = typename FastIntegerArithmeticPromotion<T, U>::type;
178 // Verify the destination type can hold the result (always true for 0).
179 if (BASE_NUMERICS_UNLIKELY((!IsValueInRangeForNumericType<Promotion>(x) ||
180 !IsValueInRangeForNumericType<Promotion>(y)) &&
181 x && y)) {
182 return false;
183 }
184
185 Promotion presult = {};
186 bool is_valid = true;
188 // The fast op may be available with the promoted type.
191 presult = static_cast<Promotion>(x) * static_cast<Promotion>(y);
192 } else {
193 is_valid = CheckedMulImpl(static_cast<Promotion>(x),
194 static_cast<Promotion>(y), &presult);
195 }
196 *result = static_cast<V>(presult);
197 return is_valid && IsValueInRangeForNumericType<V>(presult);
198 }
static bool is_valid(SkISize dim)
GAsyncResult * result
T __attribute__((ext_vector_type(N))) V
double y
double x
constexpr bool CheckedMulImpl(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: