Pigweed
C/C++ API Reference
|
Functions | |
template<typename A , typename B , typename T > | |
constexpr bool | pw::CheckedAdd (A a, B b, T &result) |
template<typename T , typename A , typename B > | |
constexpr std::optional< T > | pw::CheckedAdd (A a, B b) |
template<typename T , typename Inc > | |
constexpr bool | pw::CheckedIncrement (T &base, Inc inc) |
template<typename A , typename B , typename T > | |
constexpr bool | pw::CheckedSub (A a, B b, T &result) |
template<typename T , typename A , typename B > | |
constexpr std::optional< T > | pw::CheckedSub (A a, B b) |
template<typename T , typename Dec > | |
constexpr bool | pw::CheckedDecrement (T &base, Dec dec) |
template<typename A , typename B , typename T > | |
constexpr bool | pw::CheckedMul (A a, B b, T &result) |
template<typename T , typename A , typename B > | |
constexpr std::optional< T > | pw::CheckedMul (A a, B b) |
|
constexpr |
Adds two numbers, checking for overflow.
T | The type of the result, which is checked for overflow. |
A | The type of the first addend, a . |
B | The type of the second addend, b . |
[in] | a | The first addend. |
[in] | b | The second addend. |
a + b
) if addition was successful, or nullopt
if the addition would overflow.pw::CheckedAdd<uint32_t>(...)
.
|
constexpr |
Adds two numbers, checking for overflow.
A | The type of the first addend, a . |
B | The type of the second addend, b . |
T | The type of the result, which is checked for overflow. |
[in] | a | The first addend. |
[in] | b | The second addend. |
[out] | result | Reference to t |
a + b
) if addition was successful, or false
if the addition would overflow and result
is unmodified.pw::CheckedAdd<uint32_t>(...)
.
|
constexpr |
Decrements a variable by some amount.
T | The type of the variable to be decremented. |
Dec | The type of the variable to subtract. |
[in] | base | The variable to be decremented. |
[in] | dec | The number to subtract from base . |
base
was decremented (base -= dec
); False if the subtraction would overflow and base
is unmodified.
|
constexpr |
Increments a variable by some amount.
T | The type of the variable to be incremented. |
Inc | The type of the variable to add. |
[in] | base | The variable to be incremented. |
[in] | inc | The number to add to base . |
base
was incremented (base += inc
); False if the addition would overflow and base
is unmodified.
|
constexpr |
Multiplies two numbers, checking for overflow.
T | The type of the result, which is checked for overflow. |
A | The type of the first factor, a . |
B | The type of the second factor, b . |
[in] | a | The first factor. |
[in] | b | The second factor. |
a * b
) if multiplication was successful, or nullopt
if the multiplication would overflow.pw::CheckedMul<uint32_t>(...)
.
|
constexpr |
Multiplies two numbers, checking for overflow.
A | The type of the first addend, a . |
B | The type of the second addend, b . |
T | The type of the result, which is checked for overflow. |
[in] | a | The first addend. |
[in] | b | The second addend. |
[out] | result | Reference to the result. |
true
if the multiplication was successful, false
if it would overflow.pw::CheckedMul<uint32_t>(...)
.
|
constexpr |
Subtracts two numbers, checking for overflow.
T | The type of the result, which is checked for overflow. |
A | The type of the minuend, a . |
B | The type of the subtrahend, b . |
[in] | a | The minuend (the number from which b is subtracted). |
[in] | b | The subtrahend (the number subtracted from a ). |
a - b
) if subtraction was successful, or nullopt
if the subtraction would overflow.pw::CheckedSub<uint32_t>(...)
.
|
constexpr |
Subtracts two numbers, checking for overflow.
A | The type of the first addend, a . |
B | The type of the second addend, b . |
T | The type of the result, which is checked for overflow. |
[in] | a | The first addend. |
[in] | b | The second addend. |
[out] | result | Reference to the result. |
true
if the subtraction was successful, false
if it would overflow and result
is unmodified.pw::CheckedSub<uint32_t>(...)
.