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

#include <clamped_math_impl.h>

Public Types

using result_type = T
 

Static Public Member Functions

template<typename V = result_type>
static constexpr V Do (T x, U shift)
 

Detailed Description

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

Definition at line 191 of file clamped_math_impl.h.

Member Typedef Documentation

◆ result_type

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

Definition at line 195 of file clamped_math_impl.h.

Member Function Documentation

◆ Do()

template<typename T , typename U >
template<typename V = result_type>
static constexpr V base::internal::ClampedLshOp< T, U, typename std::enable_if< std::is_integral< T >::value &&std::is_integral< U >::value >::type >::Do ( T  x,
shift 
)
inlinestaticconstexpr

Definition at line 197 of file clamped_math_impl.h.

197 {
198 static_assert(!std::is_signed<U>::value, "Shift value must be unsigned.");
199 if (BASE_NUMERICS_LIKELY(shift < std::numeric_limits<T>::digits)) {
200 // Shift as unsigned to avoid undefined behavior.
201 V result = static_cast<V>(as_unsigned(x) << shift);
202 // If the shift can be reversed, we know it was valid.
203 if (BASE_NUMERICS_LIKELY(result >> shift == x))
204 return result;
205 }
206 return x ? CommonMaxOrMin<V>(IsValueNegative(x)) : 0;
207 }
GAsyncResult * result
T __attribute__((ext_vector_type(N))) V
double x
constexpr bool IsValueNegative(T value)
constexpr std::make_unsigned< typenamebase::internal::UnderlyingType< Src >::type >::type as_unsigned(const Src value)
#define BASE_NUMERICS_LIKELY(x)

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