#ifndef BASE_NUMERICS_CHECKED_MATH_H_
#define BASE_NUMERICS_CHECKED_MATH_H_
#include <stdint.h>
#include <limits>
#include <type_traits>
#include "base/numerics/checked_math_impl.h"
#include "base/numerics/safe_conversions.h"
#include "base/numerics/safe_math_shared_impl.h"
namespace 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> 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> class M,
typename L,
typename R,
typename... Args>
constexpr auto CheckMathOp(const L lhs, const R rhs, const Args... args) { … }
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Add, +, +=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Sub, -, -=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Mul, *, *=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Div, /, /=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Mod, %, %=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Lsh, <<, <<=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Rsh, >>, >>=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, And, &, &=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Or, |, |=)
BASE_NUMERIC_ARITHMETIC_OPERATORS(Checked, Check, Xor, ^, ^=)
BASE_NUMERIC_ARITHMETIC_VARIADIC(…)
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