Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
base::internal::ClampedNumeric< T > Class Template Reference

#include <clamped_math.h>

Public Types

using type = T
 

Public Member Functions

constexpr ClampedNumeric ()
 
template<typename Src >
constexpr ClampedNumeric (const ClampedNumeric< Src > &rhs)
 
template<typename Src >
constexpr ClampedNumeric (Src value)
 
template<typename Src >
constexpr ClampedNumeric (StrictNumeric< Src > value)
 
template<typename Dst >
constexpr ClampedNumeric< typename UnderlyingType< Dst >::typeCast () const
 
template<typename Src >
constexpr ClampedNumericoperator+= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator-= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator*= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator/= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator%= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator<<= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator>>= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator&= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator|= (const Src rhs)
 
template<typename Src >
constexpr ClampedNumericoperator^= (const Src rhs)
 
constexpr ClampedNumeric operator- () const
 
constexpr ClampedNumeric operator~ () const
 
constexpr ClampedNumeric Abs () const
 
template<typename U >
constexpr ClampedNumeric< typename MathWrapper< ClampedMaxOp, T, U >::typeMax (const U rhs) const
 
template<typename U >
constexpr ClampedNumeric< typename MathWrapper< ClampedMinOp, T, U >::typeMin (const U rhs) const
 
constexpr ClampedNumeric< typename UnsignedOrFloatForSize< T >::typeUnsignedAbs () const
 
constexpr ClampedNumericoperator++ ()
 
constexpr ClampedNumeric operator++ (int)
 
constexpr ClampedNumericoperator-- ()
 
constexpr ClampedNumeric operator-- (int)
 
template<template< typename, typename, typename > class M, typename R >
constexpr ClampedNumericMathOp (const R rhs)
 
template<typename Dst >
constexpr operator Dst () const
 
constexpr T RawValue () const
 

Static Public Member Functions

template<template< typename, typename, typename > class M, typename L , typename R >
static constexpr ClampedNumeric MathOp (const L lhs, const R rhs)
 

Friends

template<typename Src >
class ClampedNumeric
 

Detailed Description

template<typename T>
class base::internal::ClampedNumeric< T >

Definition at line 18 of file clamped_math.h.

Member Typedef Documentation

◆ type

template<typename T >
using base::internal::ClampedNumeric< T >::type = T

Definition at line 23 of file clamped_math.h.

Constructor & Destructor Documentation

◆ ClampedNumeric() [1/4]

template<typename T >
constexpr base::internal::ClampedNumeric< T >::ClampedNumeric ( )
inlineconstexpr

Definition at line 25 of file clamped_math.h.

25: value_(0) {}

◆ ClampedNumeric() [2/4]

template<typename T >
template<typename Src >
constexpr base::internal::ClampedNumeric< T >::ClampedNumeric ( const ClampedNumeric< Src > &  rhs)
inlineconstexpr

Definition at line 29 of file clamped_math.h.

30 : value_(saturated_cast<T>(rhs.value_)) {}

◆ ClampedNumeric() [3/4]

template<typename T >
template<typename Src >
constexpr base::internal::ClampedNumeric< T >::ClampedNumeric ( Src  value)
inlineconstexpr

Definition at line 38 of file clamped_math.h.

39 : value_(saturated_cast<T>(value)) {
40 static_assert(std::is_arithmetic<Src>::value, "Argument must be numeric.");
41 }
uint8_t value

◆ ClampedNumeric() [4/4]

template<typename T >
template<typename Src >
constexpr base::internal::ClampedNumeric< T >::ClampedNumeric ( StrictNumeric< Src >  value)
inlineconstexpr

Definition at line 46 of file clamped_math.h.

48 : value_(saturated_cast<T>(static_cast<Src>(value))) {}

Member Function Documentation

◆ Abs()

template<typename T >
constexpr ClampedNumeric base::internal::ClampedNumeric< T >::Abs ( ) const
inlineconstexpr

Definition at line 89 of file clamped_math.h.

89 {
90 // The negation of two's complement int min is int min, so that's the
91 // only overflow case where we will saturate.
92 return ClampedNumeric<T>(SaturatedAbsWrapper(value_));
93 }
constexpr T SaturatedAbsWrapper(T value)

◆ Cast()

template<typename T >
template<typename Dst >
constexpr ClampedNumeric< typename UnderlyingType< Dst >::type > base::internal::ClampedNumeric< T >::Cast ( ) const
inlineconstexpr

Definition at line 53 of file clamped_math.h.

53 {
54 return *this;
55 }

◆ MathOp() [1/2]

template<typename T >
template<template< typename, typename, typename > class M, typename L , typename R >
static constexpr ClampedNumeric base::internal::ClampedNumeric< T >::MathOp ( const L  lhs,
const R  rhs 
)
inlinestaticconstexpr

Definition at line 147 of file clamped_math.h.

147 {
148 using Math = typename MathWrapper<M, L, R>::math;
149 return ClampedNumeric<T>(
150 Math::template Do<T>(Wrapper<L>::value(lhs), Wrapper<R>::value(rhs)));
151 }
M< typename UnderlyingType< L >::type, typename UnderlyingType< R >::type, void > math

◆ MathOp() [2/2]

template<typename T >
template<template< typename, typename, typename > class M, typename R >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::MathOp ( const R  rhs)
inlineconstexpr

Definition at line 155 of file clamped_math.h.

155 {
156 using Math = typename MathWrapper<M, T, R>::math;
157 *this =
158 ClampedNumeric<T>(Math::template Do<T>(value_, Wrapper<R>::value(rhs)));
159 return *this;
160 }

◆ Max()

template<typename T >
template<typename U >
constexpr ClampedNumeric< typename MathWrapper< ClampedMaxOp, T, U >::type > base::internal::ClampedNumeric< T >::Max ( const U  rhs) const
inlineconstexpr

Definition at line 96 of file clamped_math.h.

97 {
98 using result_type = typename MathWrapper<ClampedMaxOp, T, U>::type;
99 return ClampedNumeric<result_type>(
100 ClampedMaxOp<T, U>::Do(value_, Wrapper<U>::value(rhs)));
101 }
typename math::result_type type

◆ Min()

template<typename T >
template<typename U >
constexpr ClampedNumeric< typename MathWrapper< ClampedMinOp, T, U >::type > base::internal::ClampedNumeric< T >::Min ( const U  rhs) const
inlineconstexpr

Definition at line 104 of file clamped_math.h.

105 {
106 using result_type = typename MathWrapper<ClampedMinOp, T, U>::type;
107 return ClampedNumeric<result_type>(
108 ClampedMinOp<T, U>::Do(value_, Wrapper<U>::value(rhs)));
109 }

◆ operator Dst()

template<typename T >
template<typename Dst >
constexpr base::internal::ClampedNumeric< T >::operator Dst ( ) const
inlineconstexpr

Definition at line 163 of file clamped_math.h.

163 {
165 value_);
166 }
GLenum type

◆ operator%=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator%= ( const Src  rhs)
constexpr

◆ operator&=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator&= ( const Src  rhs)
constexpr

◆ operator*=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator*= ( const Src  rhs)
constexpr

◆ operator++() [1/2]

template<typename T >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator++ ( )
inlineconstexpr

Definition at line 120 of file clamped_math.h.

120 {
121 *this += 1;
122 return *this;
123 }

◆ operator++() [2/2]

template<typename T >
constexpr ClampedNumeric base::internal::ClampedNumeric< T >::operator++ ( int  )
inlineconstexpr

Definition at line 125 of file clamped_math.h.

125 {
126 ClampedNumeric value = *this;
127 *this += 1;
128 return value;
129 }

◆ operator+=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator+= ( const Src  rhs)
constexpr

◆ operator-()

template<typename T >
constexpr ClampedNumeric base::internal::ClampedNumeric< T >::operator- ( ) const
inlineconstexpr

Definition at line 79 of file clamped_math.h.

79 {
80 // The negation of two's complement int min is int min, so that's the
81 // only overflow case where we will saturate.
82 return ClampedNumeric<T>(SaturatedNegWrapper(value_));
83 }
constexpr T SaturatedNegWrapper(T value)

◆ operator--() [1/2]

template<typename T >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator-- ( )
inlineconstexpr

Definition at line 131 of file clamped_math.h.

131 {
132 *this -= 1;
133 return *this;
134 }

◆ operator--() [2/2]

template<typename T >
constexpr ClampedNumeric base::internal::ClampedNumeric< T >::operator-- ( int  )
inlineconstexpr

Definition at line 136 of file clamped_math.h.

136 {
137 ClampedNumeric value = *this;
138 *this -= 1;
139 return value;
140 }

◆ operator-=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator-= ( const Src  rhs)
constexpr

◆ operator/=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator/= ( const Src  rhs)
constexpr

◆ operator<<=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator<<= ( const Src  rhs)
constexpr

◆ operator>>=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator>>= ( const Src  rhs)
constexpr

◆ operator^=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator^= ( const Src  rhs)
constexpr

◆ operator|=()

template<typename T >
template<typename Src >
constexpr ClampedNumeric & base::internal::ClampedNumeric< T >::operator|= ( const Src  rhs)
constexpr

◆ operator~()

template<typename T >
constexpr ClampedNumeric base::internal::ClampedNumeric< T >::operator~ ( ) const
inlineconstexpr

Definition at line 85 of file clamped_math.h.

85 {
86 return ClampedNumeric<decltype(InvertWrapper(T()))>(InvertWrapper(value_));
87 }
constexpr std::make_unsigned< T >::type InvertWrapper(T value)

◆ RawValue()

template<typename T >
constexpr T base::internal::ClampedNumeric< T >::RawValue ( ) const
inlineconstexpr

Definition at line 171 of file clamped_math.h.

171{ return value_; }

◆ UnsignedAbs()

template<typename T >
constexpr ClampedNumeric< typename UnsignedOrFloatForSize< T >::type > base::internal::ClampedNumeric< T >::UnsignedAbs ( ) const
inlineconstexpr

Definition at line 115 of file clamped_math.h.

115 {
117 SafeUnsignedAbs(value_));
118 }
constexpr std::make_unsigned< T >::type SafeUnsignedAbs(T value)

Friends And Related Function Documentation

◆ ClampedNumeric

template<typename T >
template<typename Src >
friend class ClampedNumeric
friend

Definition at line 33 of file clamped_math.h.


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