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

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

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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
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 "safe_math_impl.h" 8 #include "safe_math_impl.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // ValueUnsafe() - DO NOT USE THIS IN EXTERNAL CODE - It is public right now 103 // ValueUnsafe() - DO NOT USE THIS IN EXTERNAL CODE - It is public right now
104 // for tests and to avoid a big matrix of friend operator overloads. But the 104 // for tests and to avoid a big matrix of friend operator overloads. But the
105 // values it returns are likely to change in the future. 105 // values it returns are likely to change in the future.
106 // Returns: the raw numeric value, regardless of the current state. 106 // Returns: the raw numeric value, regardless of the current state.
107 // TODO(jschuh): crbug.com/332611 Figure out and implement semantics for 107 // TODO(jschuh): crbug.com/332611 Figure out and implement semantics for
108 // saturation/wrapping so we can expose this state consistently and implement 108 // saturation/wrapping so we can expose this state consistently and implement
109 // saturated arithmetic. 109 // saturated arithmetic.
110 T ValueUnsafe() const { return state_.value(); } 110 T ValueUnsafe() const { return state_.value(); }
111 111
112 // Prototypes for the supported arithmetic operator overloads. 112 // Prototypes for the supported arithmetic operator overloads.
113 template <typename Src> CheckedNumeric& operator+=(Src rhs); 113 template <typename Src>
114 template <typename Src> CheckedNumeric& operator-=(Src rhs); 114 CheckedNumeric& operator+=(Src rhs);
115 template <typename Src> CheckedNumeric& operator*=(Src rhs); 115 template <typename Src>
116 template <typename Src> CheckedNumeric& operator/=(Src rhs); 116 CheckedNumeric& operator-=(Src rhs);
117 template <typename Src> CheckedNumeric& operator%=(Src rhs); 117 template <typename Src>
118 CheckedNumeric& operator*=(Src rhs);
119 template <typename Src>
120 CheckedNumeric& operator/=(Src rhs);
121 template <typename Src>
122 CheckedNumeric& operator%=(Src rhs);
118 123
119 CheckedNumeric operator-() const { 124 CheckedNumeric operator-() const {
120 RangeConstraint validity; 125 RangeConstraint validity;
121 T value = CheckedNeg(state_.value(), &validity); 126 T value = CheckedNeg(state_.value(), &validity);
122 // Negation is always valid for floating point. 127 // Negation is always valid for floating point.
123 if (std::numeric_limits<T>::is_iec559) 128 if (std::numeric_limits<T>::is_iec559)
124 return CheckedNumeric<T>(value); 129 return CheckedNumeric<T>(value);
125 130
126 validity = GetRangeConstraint(state_.validity() | validity); 131 validity = GetRangeConstraint(state_.validity() | validity);
127 return CheckedNumeric<T>(value, validity); 132 return CheckedNumeric<T>(value, validity);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 267
263 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS 268 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS
264 269
265 } // namespace internal 270 } // namespace internal
266 271
267 using internal::CheckedNumeric; 272 using internal::CheckedNumeric;
268 273
269 } // namespace base 274 } // namespace base
270 275
271 #endif // BASE_SAFE_MATH_H_ 276 #endif // BASE_SAFE_MATH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698