Flutter Engine
The Flutter Engine
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
base::internal::NarrowingRange< Dst, Src, Bounds > Struct Template Reference

#include <safe_conversions_impl.h>

Public Types

using SrcLimits = std::numeric_limits< Src >
 
using DstLimits = typename std::numeric_limits< Dst >
 

Static Public Member Functions

template<typename T , typename std::enable_if< std::is_integral< T >::value >::type * = nullptr>
static constexpr T Adjust (T value)
 
template<typename T , typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr>
static constexpr T Adjust (T value)
 
static constexpr Dst max ()
 
static constexpr Dst lowest ()
 

Static Public Attributes

static const int kShift
 

Detailed Description

template<typename Dst, typename Src, template< typename > class Bounds>
struct base::internal::NarrowingRange< Dst, Src, Bounds >

Definition at line 239 of file safe_conversions_impl.h.

Member Typedef Documentation

◆ DstLimits

template<typename Dst , typename Src , template< typename > class Bounds>
using base::internal::NarrowingRange< Dst, Src, Bounds >::DstLimits = typename std::numeric_limits<Dst>

Definition at line 241 of file safe_conversions_impl.h.

◆ SrcLimits

template<typename Dst , typename Src , template< typename > class Bounds>
using base::internal::NarrowingRange< Dst, Src, Bounds >::SrcLimits = std::numeric_limits<Src>

Definition at line 240 of file safe_conversions_impl.h.

Member Function Documentation

◆ Adjust() [1/2]

template<typename Dst , typename Src , template< typename > class Bounds>
template<typename T , typename std::enable_if< std::is_integral< T >::value >::type * = nullptr>
static constexpr T base::internal::NarrowingRange< Dst, Src, Bounds >::Adjust ( T  value)
inlinestaticconstexpr

Definition at line 255 of file safe_conversions_impl.h.

255 {
256 static_assert(std::is_same<T, Dst>::value, "");
257 static_assert(kShift < DstLimits::digits, "");
258 return static_cast<T>(
259 ConditionalNegate(SafeUnsignedAbs(value) & ~((T(1) << kShift) - T(1)),
261 }
uint8_t value
constexpr bool IsValueNegative(T value)
constexpr std::make_unsigned< T >::type SafeUnsignedAbs(T value)
constexpr std::make_signed< T >::type ConditionalNegate(T x, bool is_negative)
#define T
Definition: precompiler.cc:65

◆ Adjust() [2/2]

template<typename Dst , typename Src , template< typename > class Bounds>
template<typename T , typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr>
static constexpr T base::internal::NarrowingRange< Dst, Src, Bounds >::Adjust ( T  value)
inlinestaticconstexpr

Definition at line 266 of file safe_conversions_impl.h.

266 {
267 static_assert(std::is_same<T, Dst>::value, "");
268 static_assert(kShift == 0, "");
269 return value;
270 }

◆ lowest()

template<typename Dst , typename Src , template< typename > class Bounds>
static constexpr Dst base::internal::NarrowingRange< Dst, Src, Bounds >::lowest ( )
inlinestaticconstexpr

Definition at line 273 of file safe_conversions_impl.h.

273{ return Adjust(Bounds<Dst>::lowest()); }
static constexpr T Adjust(T value)

◆ max()

template<typename Dst , typename Src , template< typename > class Bounds>
static constexpr Dst base::internal::NarrowingRange< Dst, Src, Bounds >::max ( )
inlinestaticconstexpr

Definition at line 272 of file safe_conversions_impl.h.

272{ return Adjust(Bounds<Dst>::max()); }
static float max(float r, float g, float b)
Definition: hsl.cpp:49

Member Data Documentation

◆ kShift

template<typename Dst , typename Src , template< typename > class Bounds>
const int base::internal::NarrowingRange< Dst, Src, Bounds >::kShift
static
Initial value:
=
SrcLimits::digits < DstLimits::digits)
? (DstLimits::digits - SrcLimits::digits)
: 0

Definition at line 244 of file safe_conversions_impl.h.


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