8#ifndef V8_BASE_NUMERICS_CLAMPED_MATH_IMPL_H_
9#define V8_BASE_NUMERICS_CLAMPED_MATH_IMPL_H_
25 requires(std::signed_integral<T>)
30 : std::numeric_limits<T>::max())
35 requires(std::unsigned_integral<T>)
41 requires(std::floating_point<T>)
47 requires(std::integral<T>)
57 return static_cast<T
>(
63 requires(std::floating_point<T>)
68template <
typename T,
typename U>
71template <
typename T,
typename U>
72 requires(std::integral<T> && std::integral<U>)
75 template <
typename V = result_type>
76 requires(std::same_as<V, result_type> || kIsTypeInRangeForNumericType<U, V>)
77 static constexpr V Do(T
x, U
y) {
90template <
typename T,
typename U>
93template <
typename T,
typename U>
94 requires(std::integral<T> && std::integral<U>)
97 template <
typename V = result_type>
98 requires(std::same_as<V, result_type> || kIsTypeInRangeForNumericType<U, V>)
99 static constexpr V Do(T
x, U
y) {
112template <
typename T,
typename U>
115template <
typename T,
typename U>
116 requires(std::integral<T> && std::integral<U>)
119 template <
typename V = result_type>
134template <
typename T,
typename U>
137template <
typename T,
typename U>
138 requires(std::integral<T> && std::integral<U>)
141 template <
typename V = result_type>
153template <
typename T,
typename U>
156template <
typename T,
typename U>
157 requires(std::integral<T> && std::integral<U>)
160 template <
typename V = result_type>
170template <
typename T,
typename U>
175template <
typename T,
typename U>
176 requires(std::integral<T> && std::unsigned_integral<U>)
179 template <
typename V = result_type>
180 static constexpr V Do(T
x, U shift) {
181 if (shift < std::numeric_limits<T>::digits) [[likely]] {
185 if (
result >> shift ==
x) [[likely]] {
193template <
typename T,
typename U>
197template <
typename T,
typename U>
198 requires(std::integral<T> && std::unsigned_integral<U>)
201 template <
typename V = result_type>
202 static constexpr V Do(T
x, U shift) {
212template <
typename T,
typename U>
215template <
typename T,
typename U>
216 requires(std::integral<T> && std::integral<U>)
218 using result_type = std::make_unsigned_t<MaxExponentPromotion<T, U>>;
219 template <
typename V>
225template <
typename T,
typename U>
229template <
typename T,
typename U>
230 requires(std::integral<T> && std::integral<U>)
232 using result_type = std::make_unsigned_t<MaxExponentPromotion<T, U>>;
233 template <
typename V>
239template <
typename T,
typename U>
243template <
typename T,
typename U>
244 requires(std::integral<T> && std::integral<U>)
246 using result_type = std::make_unsigned_t<MaxExponentPromotion<T, U>>;
247 template <
typename V>
253template <
typename T,
typename U>
256template <
typename T,
typename U>
257 requires(std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
260 template <
typename V = result_type>
267template <
typename T,
typename U>
270template <
typename T,
typename U>
271 requires(std::is_arithmetic_v<T> && std::is_arithmetic_v<U>)
274 template <
typename V = result_type>
283#define BASE_FLOAT_ARITHMETIC_OPS(NAME, OP) \
284 template <typename T, typename U> \
285 requires(std::floating_point<T> || std::floating_point<U>) \
286 struct Clamped##NAME##Op<T, U> { \
287 using result_type = MaxExponentPromotion<T, U>; \
288 template <typename V = result_type> \
289 static constexpr V Do(T x, U y) { \
290 return saturated_cast<V>(x OP y); \
299#undef BASE_FLOAT_ARITHMETIC_OPS
#define BASE_FLOAT_ARITHMETIC_OPS(NAME, OP)
ZoneVector< RpoNumber > & result
constexpr auto SafeUnsignedAbs(T value)
constexpr bool IsValueNegative(T value)
constexpr T NegateWrapper(T value)
constexpr int kIntegerBitsPlusSign
constexpr auto as_unsigned(Src value)
constexpr T SaturatedAbsWrapper(T value)
constexpr T SaturatedNegWrapper(T value)
std::conditional_t< std::is_signed_v< Lhs > ?(!std::is_signed_v< Rhs >||kMaxExponent< Lhs > > kMaxExponent< Rhs >) :(!std::is_signed_v< Rhs > &&kMaxExponent< Lhs >< kMaxExponent< Rhs >), Lhs, Rhs > LowestValuePromotion
constexpr Dst CommonMaxOrMin(bool is_min)
std::conditional_t<(kMaxExponent< Lhs > > kMaxExponent< Rhs >), Lhs, Rhs > MaxExponentPromotion
constexpr Dst saturated_cast(Src value)
static constexpr V Do(T x, U y)
MaxExponentPromotion< T, U > result_type
std::make_unsigned_t< MaxExponentPromotion< T, U > > result_type
static constexpr V Do(T x, U y)
static constexpr V Do(T x, U y)
MaxExponentPromotion< T, U > result_type
static constexpr V Do(T x, U shift)
MaxExponentPromotion< T, U > result_type
static constexpr V Do(T x, U y)
static constexpr V Do(T x, U y)
LowestValuePromotion< T, U > result_type
static constexpr V Do(T x, U y)
MaxExponentPromotion< T, U > result_type
static constexpr V Do(T x, U y)
MaxExponentPromotion< T, U > result_type
std::make_unsigned_t< MaxExponentPromotion< T, U > > result_type
static constexpr V Do(T x, U y)
static constexpr V Do(T x, U shift)
MaxExponentPromotion< T, U > result_type
static constexpr V Do(T x, U y)
std::make_unsigned_t< MaxExponentPromotion< T, U > > result_type
static constexpr V Do(T x, U y)
static constexpr bool Test(L lhs, R rhs)
static constexpr bool Test(L lhs, R rhs)
std::unique_ptr< ValueMirror > value