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

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

Issue 1547833002: Switch from nonstd::unique_ptr to std::unique_ptr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 12 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 PDFIUM_THIRD_PARTY_BASE_SAFE_MATH_H_ 5 #ifndef PDFIUM_THIRD_PARTY_BASE_SAFE_MATH_H_
6 #define PDFIUM_THIRD_PARTY_BASE_SAFE_MATH_H_ 6 #define PDFIUM_THIRD_PARTY_BASE_SAFE_MATH_H_
7 7
8 #include "safe_math_impl.h" 8 #include "safe_math_impl.h"
9 9
10 namespace pdfium { 10 namespace pdfium {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 *this -= 1; 159 *this -= 1;
160 return value; 160 return value;
161 } 161 }
162 162
163 // These static methods behave like a convenience cast operator targeting 163 // These static methods behave like a convenience cast operator targeting
164 // the desired CheckedNumeric type. As an optimization, a reference is 164 // the desired CheckedNumeric type. As an optimization, a reference is
165 // returned when Src is the same type as T. 165 // returned when Src is the same type as T.
166 template <typename Src> 166 template <typename Src>
167 static CheckedNumeric<T> cast( 167 static CheckedNumeric<T> cast(
168 Src u, 168 Src u,
169 typename enable_if<std::numeric_limits<Src>::is_specialized, int>::type = 169 typename std::enable_if<std::numeric_limits<Src>::is_specialized,
170 0) { 170 int>::type = 0) {
171 return u; 171 return u;
172 } 172 }
173 173
174 template <typename Src> 174 template <typename Src>
175 static CheckedNumeric<T> cast( 175 static CheckedNumeric<T> cast(
176 const CheckedNumeric<Src>& u, 176 const CheckedNumeric<Src>& u,
177 typename enable_if<!is_same<Src, T>::value, int>::type = 0) { 177 typename std::enable_if<!std::is_same<Src, T>::value, int>::type = 0) {
178 return u; 178 return u;
179 } 179 }
180 180
181 static const CheckedNumeric<T>& cast(const CheckedNumeric<T>& u) { return u; } 181 static const CheckedNumeric<T>& cast(const CheckedNumeric<T>& u) { return u; }
182 182
183 private: 183 private:
184 CheckedNumericState<T> state_; 184 CheckedNumericState<T> state_;
185 }; 185 };
186 186
187 // This is the boilerplate for the standard arithmetic operator overloads. A 187 // This is the boilerplate for the standard arithmetic operator overloads. A
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS 263 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS
264 264
265 } // namespace internal 265 } // namespace internal
266 266
267 using internal::CheckedNumeric; 267 using internal::CheckedNumeric;
268 268
269 } // namespace base 269 } // namespace base
270 } // namespace pdfium 270 } // namespace pdfium
271 271
272 #endif // PDFIUM_THIRD_PARTY_BASE_SAFE_MATH_H_ 272 #endif // PDFIUM_THIRD_PARTY_BASE_SAFE_MATH_H_
OLDNEW
« no previous file with comments | « third_party/base/numerics/safe_conversions_impl.h ('k') | third_party/base/numerics/safe_math_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698