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

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

Issue 1475233002: Remove base::enable_if (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/numerics/safe_conversions.h ('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_NUMERICS_SAFE_MATH_H_ 5 #ifndef BASE_NUMERICS_SAFE_MATH_H_
6 #define BASE_NUMERICS_SAFE_MATH_H_ 6 #define BASE_NUMERICS_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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 *this -= 1; 174 *this -= 1;
175 return value; 175 return value;
176 } 176 }
177 177
178 // These static methods behave like a convenience cast operator targeting 178 // These static methods behave like a convenience cast operator targeting
179 // the desired CheckedNumeric type. As an optimization, a reference is 179 // the desired CheckedNumeric type. As an optimization, a reference is
180 // returned when Src is the same type as T. 180 // returned when Src is the same type as T.
181 template <typename Src> 181 template <typename Src>
182 static CheckedNumeric<T> cast( 182 static CheckedNumeric<T> cast(
183 Src u, 183 Src u,
184 typename enable_if<std::numeric_limits<Src>::is_specialized, int>::type = 184 typename std::enable_if<std::numeric_limits<Src>::is_specialized,
185 0) { 185 int>::type = 0) {
186 return u; 186 return u;
187 } 187 }
188 188
189 template <typename Src> 189 template <typename Src>
190 static CheckedNumeric<T> cast( 190 static CheckedNumeric<T> cast(
191 const CheckedNumeric<Src>& u, 191 const CheckedNumeric<Src>& u,
192 typename enable_if<!is_same<Src, T>::value, int>::type = 0) { 192 typename std::enable_if<!is_same<Src, T>::value, int>::type = 0) {
193 return u; 193 return u;
194 } 194 }
195 195
196 static const CheckedNumeric<T>& cast(const CheckedNumeric<T>& u) { return u; } 196 static const CheckedNumeric<T>& cast(const CheckedNumeric<T>& u) { return u; }
197 197
198 private: 198 private:
199 template <typename NumericType> 199 template <typename NumericType>
200 struct UnderlyingType { 200 struct UnderlyingType {
201 using type = NumericType; 201 using type = NumericType;
202 }; 202 };
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS 290 #undef BASE_NUMERIC_ARITHMETIC_OPERATORS
291 291
292 } // namespace internal 292 } // namespace internal
293 293
294 using internal::CheckedNumeric; 294 using internal::CheckedNumeric;
295 295
296 } // namespace base 296 } // namespace base
297 297
298 #endif // BASE_NUMERICS_SAFE_MATH_H_ 298 #endif // BASE_NUMERICS_SAFE_MATH_H_
OLDNEW
« no previous file with comments | « base/numerics/safe_conversions.h ('k') | base/numerics/safe_math_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698