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

Side by Side Diff: base/numerics/safe_math.h

Issue 596103002: Fix more disabled MSVC warnings, base/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « base/metrics/histogram_base.cc ('k') | base/numerics/safe_math_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SAFE_MATH_H_ 5 #ifndef BASE_SAFE_MATH_H_
6 #define BASE_SAFE_MATH_H_ 6 #define BASE_SAFE_MATH_H_
7 7
8 #include "base/numerics/safe_math_impl.h" 8 #include "base/numerics/safe_math_impl.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const CheckedNumeric<T>& lhs, const CheckedNumeric<T>& rhs) { \ 198 const CheckedNumeric<T>& lhs, const CheckedNumeric<T>& rhs) { \
199 typedef typename ArithmeticPromotion<T>::type Promotion; \ 199 typedef typename ArithmeticPromotion<T>::type Promotion; \
200 /* Floating point always takes the fast path */ \ 200 /* Floating point always takes the fast path */ \
201 if (std::numeric_limits<T>::is_iec559) \ 201 if (std::numeric_limits<T>::is_iec559) \
202 return CheckedNumeric<T>(lhs.ValueUnsafe() OP rhs.ValueUnsafe()); \ 202 return CheckedNumeric<T>(lhs.ValueUnsafe() OP rhs.ValueUnsafe()); \
203 if (IsIntegerArithmeticSafe<Promotion, T, T>::value) \ 203 if (IsIntegerArithmeticSafe<Promotion, T, T>::value) \
204 return CheckedNumeric<Promotion>( \ 204 return CheckedNumeric<Promotion>( \
205 lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \ 205 lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \
206 GetRangeConstraint(rhs.validity() | lhs.validity())); \ 206 GetRangeConstraint(rhs.validity() | lhs.validity())); \
207 RangeConstraint validity = RANGE_VALID; \ 207 RangeConstraint validity = RANGE_VALID; \
208 T result = Checked##NAME(static_cast<Promotion>(lhs.ValueUnsafe()), \ 208 T result = static_cast<T>(Checked##NAME( \
209 static_cast<Promotion>(rhs.ValueUnsafe()), \ 209 static_cast<Promotion>(lhs.ValueUnsafe()), \
210 &validity); \ 210 static_cast<Promotion>(rhs.ValueUnsafe()), \
211 &validity)); \
211 return CheckedNumeric<Promotion>( \ 212 return CheckedNumeric<Promotion>( \
212 result, \ 213 result, \
213 GetRangeConstraint(validity | lhs.validity() | rhs.validity())); \ 214 GetRangeConstraint(validity | lhs.validity() | rhs.validity())); \
214 } \ 215 } \
215 /* Assignment arithmetic operator implementation from CheckedNumeric. */ \ 216 /* Assignment arithmetic operator implementation from CheckedNumeric. */ \
216 template <typename T> \ 217 template <typename T> \
217 template <typename Src> \ 218 template <typename Src> \
218 CheckedNumeric<T>& CheckedNumeric<T>::operator COMPOUND_OP(Src rhs) { \ 219 CheckedNumeric<T>& CheckedNumeric<T>::operator COMPOUND_OP(Src rhs) { \
219 *this = CheckedNumeric<T>::cast(*this) OP CheckedNumeric<Src>::cast(rhs); \ 220 *this = CheckedNumeric<T>::cast(*this) OP CheckedNumeric<Src>::cast(rhs); \
220 return *this; \ 221 return *this; \
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 263
263 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS 264 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS
264 265
265 } // namespace internal 266 } // namespace internal
266 267
267 using internal::CheckedNumeric; 268 using internal::CheckedNumeric;
268 269
269 } // namespace base 270 } // namespace base
270 271
271 #endif // BASE_SAFE_MATH_H_ 272 #endif // BASE_SAFE_MATH_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram_base.cc ('k') | base/numerics/safe_math_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698