Chromium Code Reviews| Index: base/numerics/safe_conversions_impl.h |
| diff --git a/base/numerics/safe_conversions_impl.h b/base/numerics/safe_conversions_impl.h |
| index aef7135cefb8177e397a9a5729dd9282b2ff6669..713b8efbea7a0806bbc2e9693ac48592df770d92 100644 |
| --- a/base/numerics/safe_conversions_impl.h |
| +++ b/base/numerics/safe_conversions_impl.h |
| @@ -549,6 +549,7 @@ struct UnderlyingType { |
| using type = typename ArithmeticOrUnderlyingEnum<T>::type; |
| static const bool is_numeric = std::is_arithmetic<type>::value; |
| static const bool is_checked = false; |
| + static const bool is_clamped = false; |
| static const bool is_strict = false; |
| }; |
| @@ -590,14 +591,17 @@ template <typename L, typename R> |
| struct IsClampedOp { |
| static const bool value = |
| UnderlyingType<L>::is_numeric && UnderlyingType<R>::is_numeric && |
| - (UnderlyingType<L>::is_clamped || UnderlyingType<R>::is_clamped); |
| + (UnderlyingType<L>::is_clamped || UnderlyingType<R>::is_clamped) && |
| + !(UnderlyingType<L>::is_checked || UnderlyingType<R>::is_checked); |
|
dcheng
2017/06/28 07:25:06
This confused me a bit initially--why would we hav
jschuh
2017/06/28 12:32:38
I'll add it to the README. The gist is, if it can
|
| }; |
| template <typename L, typename R> |
| struct IsStrictOp { |
| static const bool value = |
| UnderlyingType<L>::is_numeric && UnderlyingType<R>::is_numeric && |
| - (UnderlyingType<L>::is_strict || UnderlyingType<R>::is_strict); |
| + (UnderlyingType<L>::is_strict || UnderlyingType<R>::is_strict) && |
| + !(UnderlyingType<L>::is_checked || UnderlyingType<R>::is_checked) && |
| + !(UnderlyingType<L>::is_clamped || UnderlyingType<R>::is_clamped); |
| }; |
| template <typename L, typename R> |