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

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

Issue 900753002: Add namespace and re-arrange PDFium's local copy of chromium /base. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rename safemath target to pdfium_base Created 5 years, 10 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 | « third_party/base/numerics/safe_conversions.h ('k') | third_party/base/numerics/safe_math.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_CONVERSIONS_IMPL_H_ 5 #ifndef PDFIUM_THIRD_PARTY_BASE_SAFE_CONVERSIONS_IMPL_H_
6 #define BASE_SAFE_CONVERSIONS_IMPL_H_ 6 #define PDFIUM_THIRD_PARTY_BASE_SAFE_CONVERSIONS_IMPL_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "../macros.h" 10 #include "../macros.h"
11 #include "../template_util.h" 11 #include "../template_util.h"
12 12
13 namespace pdfium {
13 namespace base { 14 namespace base {
14 namespace internal { 15 namespace internal {
15 16
16 // The std library doesn't provide a binary max_exponent for integers, however 17 // The std library doesn't provide a binary max_exponent for integers, however
17 // we can compute one by adding one to the number of non-sign bits. This allows 18 // we can compute one by adding one to the number of non-sign bits. This allows
18 // for accurate range comparisons between floating point and integer types. 19 // for accurate range comparisons between floating point and integer types.
19 template <typename NumericType> 20 template <typename NumericType>
20 struct MaxExponent { 21 struct MaxExponent {
21 static const int value = std::numeric_limits<NumericType>::is_iec559 22 static const int value = std::numeric_limits<NumericType>::is_iec559
22 ? std::numeric_limits<NumericType>::max_exponent 23 ? std::numeric_limits<NumericType>::max_exponent
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 inline RangeConstraint DstRangeRelationToSrcRange(Src value) { 206 inline RangeConstraint DstRangeRelationToSrcRange(Src value) {
206 COMPILE_ASSERT(std::numeric_limits<Src>::is_specialized, 207 COMPILE_ASSERT(std::numeric_limits<Src>::is_specialized,
207 argument_must_be_numeric); 208 argument_must_be_numeric);
208 COMPILE_ASSERT(std::numeric_limits<Dst>::is_specialized, 209 COMPILE_ASSERT(std::numeric_limits<Dst>::is_specialized,
209 result_must_be_numeric); 210 result_must_be_numeric);
210 return DstRangeRelationToSrcRangeImpl<Dst, Src>::Check(value); 211 return DstRangeRelationToSrcRangeImpl<Dst, Src>::Check(value);
211 } 212 }
212 213
213 } // namespace internal 214 } // namespace internal
214 } // namespace base 215 } // namespace base
216 } // namespace pdfium
215 217
216 #endif // BASE_SAFE_CONVERSIONS_IMPL_H_ 218 #endif // PDFIUM_THIRD_PARTY_BASE_SAFE_CONVERSIONS_IMPL_H_
217 219
OLDNEW
« no previous file with comments | « third_party/base/numerics/safe_conversions.h ('k') | third_party/base/numerics/safe_math.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698