Lines Matching refs:CheckedNumeric
19 class CheckedNumeric {
21 "CheckedNumeric<T>: T must be a numeric type.");
26 constexpr CheckedNumeric() = default;
30 constexpr CheckedNumeric(const CheckedNumeric<Src>& rhs)
34 friend class CheckedNumeric;
39 constexpr CheckedNumeric(Src value) // NOLINT(runtime/explicit)
47 constexpr CheckedNumeric(
51 // IsValid() - The public API to test if a CheckedNumeric is currently valid.
105 // CheckedNumeric. If the current state is invalid or the destination cannot
106 // represent the result then the returned CheckedNumeric will be invalid.
108 constexpr CheckedNumeric<typename UnderlyingType<Dst>::type> Cast() const {
116 friend U GetNumericValueForTest(const CheckedNumeric<U>& src);
120 constexpr CheckedNumeric& operator+=(const Src rhs);
122 constexpr CheckedNumeric& operator-=(const Src rhs);
124 constexpr CheckedNumeric& operator*=(const Src rhs);
126 constexpr CheckedNumeric& operator/=(const Src rhs);
128 constexpr CheckedNumeric& operator%=(const Src rhs);
130 constexpr CheckedNumeric& operator<<=(const Src rhs);
132 constexpr CheckedNumeric& operator>>=(const Src rhs);
134 constexpr CheckedNumeric& operator&=(const Src rhs);
136 constexpr CheckedNumeric& operator|=(const Src rhs);
138 constexpr CheckedNumeric& operator^=(const Src rhs);
140 constexpr CheckedNumeric operator-() const {
146 ? CheckedNumeric<T>(
155 constexpr CheckedNumeric operator~() const {
156 return CheckedNumeric<decltype(InvertWrapper(T()))>(
160 constexpr CheckedNumeric Abs() const {
165 constexpr CheckedNumeric<typename MathWrapper<CheckedMaxOp, T, U>::type> Max(
171 return CheckedNumeric<result_type>(
180 constexpr CheckedNumeric<typename MathWrapper<CheckedMinOp, T, U>::type> Min(
186 return CheckedNumeric<result_type>(
197 constexpr CheckedNumeric<typename UnsignedOrFloatForSize<T>::type>
199 return CheckedNumeric<typename UnsignedOrFloatForSize<T>::type>(
203 constexpr CheckedNumeric& operator++() {
208 constexpr CheckedNumeric operator++(int) {
209 CheckedNumeric value = *this;
214 constexpr CheckedNumeric& operator--() {
219 constexpr CheckedNumeric operator--(int) {
220 CheckedNumeric value = *this;
230 static constexpr CheckedNumeric MathOp(const L lhs, const R rhs) {
236 return CheckedNumeric<T>(result, is_valid);
241 constexpr CheckedNumeric& MathOp(const R rhs) {
246 *this = CheckedNumeric<T>(result, is_valid);
253 CheckedNumeric FastRuntimeNegate() const {
256 return CheckedNumeric<T>(result, IsValid() && success);
260 constexpr CheckedNumeric(Src value, bool is_valid)
264 // CheckedNumeric and POD arithmetic types.
272 struct Wrapper<CheckedNumeric<Src>> {
273 static constexpr bool is_valid(const CheckedNumeric<Src> v) {
276 static constexpr Src value(const CheckedNumeric<Src> v) {
292 constexpr bool IsValidForType(const CheckedNumeric<Src> value) {
298 const CheckedNumeric<Src> value) {
304 const CheckedNumeric<Src> value,
309 // Convience wrapper to return a new CheckedNumeric from the provided arithmetic
312 constexpr CheckedNumeric<typename UnderlyingType<T>::type> MakeCheckedNum(
321 constexpr CheckedNumeric<typename MathWrapper<M, L, R>::type> CheckMathOp(
325 return CheckedNumeric<typename Math::result_type>::template MathOp<M>(lhs,
334 constexpr CheckedNumeric<typename ResultType<M, L, R, Args...>::type>
376 using internal::CheckedNumeric;