![]() |
Bitcoin Core 32.1.0
P2P Digital Currency
|
#include <util/check.h>#include <climits>#include <concepts>#include <limits>#include <optional>#include <type_traits>Go to the source code of this file.
Functions | |
| template<std::integral T> | |
| bool | AdditionOverflow (const T i, const T j) noexcept |
| template<class T> | |
| std::optional< T > | CheckedAdd (const T i, const T j) noexcept |
| template<std::unsigned_integral T, std::unsigned_integral U> | |
| constexpr bool | TrySub (T &i, const U j) noexcept |
| template<std::integral T> | |
| T | SaturatingAdd (const T i, const T j) noexcept |
| template<std::unsigned_integral Dividend, std::unsigned_integral Divisor> | |
| constexpr auto | CeilDiv (const Dividend dividend, const Divisor divisor) |
| Integer ceiling division (for unsigned values). | |
| template<std::integral T> | |
| constexpr std::optional< T > | CheckedLeftShift (T input, unsigned shift) noexcept |
| Left bit shift with overflow checking. | |
| template<std::integral T> | |
| constexpr T | SaturatingLeftShift (T input, unsigned shift) noexcept |
| Left bit shift with safe minimum and maximum values. | |
Definition at line 17 of file overflow.h.
|
nodiscardconstexpr |
Integer ceiling division (for unsigned values).
Computes the smallest integer q such that q * divisor >= dividend. Both dividend and divisor must be unsigned, and divisor must be non-zero.
The implementation avoids overflow that can occur with (dividend + divisor - 1) / divisor.
Definition at line 70 of file overflow.h.
Definition at line 27 of file overflow.h.
|
constexprnoexcept |
Left bit shift with overflow checking.
| input | The input value to be left shifted. |
| shift | The number of bits to left shift. |
Definition at line 83 of file overflow.h.
Definition at line 44 of file overflow.h.
Left bit shift with safe minimum and maximum values.
| input | The input value to be left shifted. |
| shift | The number of bits to left shift. |
Definition at line 102 of file overflow.h.
|
nodiscardconstexprnoexcept |
Definition at line 36 of file overflow.h.