#ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_NUMERICS_CHECKED_MATH_H_
#define PARTITION_ALLOC_PARTITION_ALLOC_BASE_NUMERICS_CHECKED_MATH_H_
#include <cstddef>
#include <limits>
#include <type_traits>
#include "partition_alloc/partition_alloc_base/numerics/checked_math_impl.h"
namespace partition_alloc::internal::base {
namespace internal {
template <typename T>
class CheckedNumeric { … };
template <typename Dst, typename Src>
constexpr bool IsValidForType(const CheckedNumeric<Src> value) { … }
template <typename Dst, typename Src>
constexpr StrictNumeric<Dst> ValueOrDieForType(
const CheckedNumeric<Src> value) { … }
template <typename Dst, typename Src, typename Default>
constexpr StrictNumeric<Dst> ValueOrDefaultForType(
const CheckedNumeric<Src> value,
const Default default_value) { … }
template <typename T>
constexpr CheckedNumeric<typename UnderlyingType<T>::type> MakeCheckedNum(
const T value) { … }
template <template <typename, typename, typename> class M,
typename L,
typename R>
constexpr CheckedNumeric<typename MathWrapper<M, L, R>::type> CheckMathOp(
const L lhs,
const R rhs) { … }
template <template <typename, typename, typename> class M,
typename L,
typename R,
typename... Args>
constexpr auto CheckMathOp(const L lhs, const R rhs, const Args... args) { … }
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Add, +, +=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Sub, -, -=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Mul, *, *=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Div, /, /=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Mod, %, %=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Lsh, <<, <<=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Rsh, >>, >>=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, And, &, &=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Or, |, |=)
PA_BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Xor, ^, ^=)
PA_BASE_NUMERIC_ARITHMETIC_VARIADIC(…)
PA_BASE_NUMERIC_ARITHMETIC_VARIADIC(…)
template <typename L, typename R>
L* operator+(L* lhs, const StrictNumeric<R> rhs) { … }
template <typename L, typename R>
L* operator-(L* lhs, const StrictNumeric<R> rhs) { … }
}
CheckAdd;
CheckAnd;
CheckDiv;
CheckedNumeric;
CheckLsh;
CheckMax;
CheckMin;
CheckMod;
CheckMul;
CheckOr;
CheckRsh;
CheckSub;
CheckXor;
IsValidForType;
MakeCheckedNum;
ValueOrDefaultForType;
ValueOrDieForType;
}
#endif