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

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

Issue 2529413002: Loosen restrictions on CheckedNumeric bitwise operators (Closed)
Patch Set: docs and cast Created 4 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 | « no previous file | base/numerics/safe_math_impl.h » ('j') | base/numerics/safe_math_impl.h » ('J')
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <limits> 10 #include <limits>
11 #include <type_traits> 11 #include <type_traits>
12 12
13 #include "base/numerics/safe_math_impl.h" 13 #include "base/numerics/safe_math_impl.h"
14 14
15 namespace base { 15 namespace base {
16 namespace internal { 16 namespace internal {
17 17
18 // CheckedNumeric implements all the logic and operators for detecting integer 18 // CheckedNumeric implements all the logic and operators for detecting integer
19 // boundary conditions such as overflow, underflow, and invalid conversions. 19 // boundary conditions such as overflow, underflow, and invalid conversions.
20 // The CheckedNumeric type implicitly converts from floating point and integer 20 // The CheckedNumeric type implicitly converts from floating point and integer
21 // data types, and contains overloads for basic arithmetic operations (i.e.: +, 21 // data types, and contains overloads for basic arithmetic operations (i.e.: +,
22 // -, *, / for all types, % for integers, and &, |, ^ for unsigned integers). 22 // -, *, / for all types and %, <<, >>, &, |, ^ for integers; additionally the
23 // result of all bitwise logical operations is always promoted to an unsigned
24 // CheckedNumeric type matching the width of the larger operand).
23 // 25 //
24 // You may also use one of the variadic convenience functions, which accept 26 // You may also use one of the variadic convenience functions, which accept
25 // standard arithmetic or CheckedNumeric types, perform arithmetic operations, 27 // standard arithmetic or CheckedNumeric types, perform arithmetic operations,
26 // and return a CheckedNumeric result. The supported functions are: 28 // and return a CheckedNumeric result. The supported functions are:
27 // CheckAdd() - Addition. 29 // CheckAdd() - Addition.
28 // CheckSub() - Subtraction. 30 // CheckSub() - Subtraction.
29 // CheckMul() - Multiplication. 31 // CheckMul() - Multiplication.
30 // CheckDiv() - Division. 32 // CheckDiv() - Division.
31 // CheckMod() - Modulous (integer only). 33 // CheckMod() - Modulous (integer only).
32 // CheckLsh() - Left integer shift (integer only). 34 // CheckLsh() - Left integer shift (integer only).
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 using internal::CheckMod; 405 using internal::CheckMod;
404 using internal::CheckLsh; 406 using internal::CheckLsh;
405 using internal::CheckRsh; 407 using internal::CheckRsh;
406 using internal::CheckAnd; 408 using internal::CheckAnd;
407 using internal::CheckOr; 409 using internal::CheckOr;
408 using internal::CheckXor; 410 using internal::CheckXor;
409 411
410 } // namespace base 412 } // namespace base
411 413
412 #endif // BASE_NUMERICS_SAFE_MATH_H_ 414 #endif // BASE_NUMERICS_SAFE_MATH_H_
OLDNEW
« no previous file with comments | « no previous file | base/numerics/safe_math_impl.h » ('j') | base/numerics/safe_math_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698