Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: base/numerics/safe_math_shared_impl.h

Issue 2945433003: Add ClampedNumeric templates (Closed)
Patch Set: more docs and modulus Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/numerics/safe_math_shared_impl.h
diff --git a/base/numerics/safe_math_shared_impl.h b/base/numerics/safe_math_shared_impl.h
index 3e75bfecdea38aa0177fbf99ef34098a83f2ffd1..c243e2636788537406a5bd39b09cc32855995cdf 100644
--- a/base/numerics/safe_math_shared_impl.h
+++ b/base/numerics/safe_math_shared_impl.h
@@ -118,26 +118,27 @@ struct ResultType {
template <typename L, typename R, typename... Args> \
CLASS##Numeric<typename ResultType<CLASS##OP_NAME##Op, L, R, Args...>::type> \
CL_ABBR##OP_NAME(const L lhs, const R rhs, const Args... args) { \
- return ChkMathOp<CLASS##OP_NAME##Op, L, R, Args...>(lhs, rhs, args...); \
+ return CL_ABBR##MathOp<CLASS##OP_NAME##Op, L, R, Args...>(lhs, rhs, \
+ args...); \
}
#define BASE_NUMERIC_ARITHMETIC_OPERATORS(CLASS, CL_ABBR, OP_NAME, OP, CMP_OP) \
- /* Binary arithmetic operator for all CheckedNumeric operations. */ \
+ /* Binary arithmetic operator for all CLASS##Numeric operations. */ \
template <typename L, typename R, \
- typename std::enable_if<IsCheckedOp<L, R>::value>::type* = \
+ typename std::enable_if<Is##CLASS##Op<L, R>::value>::type* = \
nullptr> \
- CheckedNumeric<typename MathWrapper<CLASS##OP_NAME##Op, L, R>::type> \
+ CLASS##Numeric<typename MathWrapper<CLASS##OP_NAME##Op, L, R>::type> \
operator OP(const L lhs, const R rhs) { \
return decltype(lhs OP rhs)::template MathOp<CLASS##OP_NAME##Op>(lhs, \
rhs); \
} \
- /* Assignment arithmetic operator implementation from CheckedNumeric. */ \
+ /* Assignment arithmetic operator implementation from CLASS##Numeric. */ \
template <typename L> \
template <typename R> \
- CheckedNumeric<L>& CheckedNumeric<L>::operator CMP_OP(const R rhs) { \
+ CLASS##Numeric<L>& CLASS##Numeric<L>::operator CMP_OP(const R rhs) { \
return MathOp<CLASS##OP_NAME##Op>(rhs); \
} \
- /* Variadic arithmetic functions that return CheckedNumeric. */ \
+ /* Variadic arithmetic functions that return CLASS##Numeric. */ \
BASE_NUMERIC_ARITHMETIC_VARIADIC(CLASS, CL_ABBR, OP_NAME)
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698