Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
base::internal::SaturateFastOp< Dst, Src, typename std::enable_if< std::is_integral< Src >::value &&std::is_integral< Dst >::value &&!SaturateFastAsmOp< Dst, Src >::is_supported >::type > Struct Template Reference

#include <safe_conversions.h>

Static Public Member Functions

static constexpr Dst Do (Src value)
 

Static Public Attributes

static constexpr bool is_supported = true
 

Detailed Description

template<typename Dst, typename Src>
struct base::internal::SaturateFastOp< Dst, Src, typename std::enable_if< std::is_integral< Src >::value &&std::is_integral< Dst >::value &&!SaturateFastAsmOp< Dst, Src >::is_supported >::type >

Definition at line 179 of file safe_conversions.h.

Member Function Documentation

◆ Do()

template<typename Dst , typename Src >
static constexpr Dst base::internal::SaturateFastOp< Dst, Src, typename std::enable_if< std::is_integral< Src >::value &&std::is_integral< Dst >::value &&!SaturateFastAsmOp< Dst, Src >::is_supported >::type >::Do ( Src  value)
inlinestaticconstexpr

Definition at line 186 of file safe_conversions.h.

186 {
187 // The exact order of the following is structured to hit the correct
188 // optimization heuristics across compilers. Do not change without
189 // checking the emitted code.
190 const Dst saturated = CommonMaxOrMin<Dst, Src>(
191 IsMaxInRangeForNumericType<Dst, Src>() ||
192 (!IsMinInRangeForNumericType<Dst, Src>() && IsValueNegative(value)));
193 return BASE_NUMERICS_LIKELY(IsValueInRangeForNumericType<Dst>(value))
194 ? static_cast<Dst>(value)
195 : saturated;
196 }
uint8_t value
constexpr bool IsValueNegative(T value)
#define BASE_NUMERICS_LIKELY(x)

Member Data Documentation

◆ is_supported

template<typename Dst , typename Src >
constexpr bool base::internal::SaturateFastOp< Dst, Src, typename std::enable_if< std::is_integral< Src >::value &&std::is_integral< Dst >::value &&!SaturateFastAsmOp< Dst, Src >::is_supported >::type >::is_supported = true
staticconstexpr

Definition at line 185 of file safe_conversions.h.


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