Wraps an integral type with overflow detection.
Synopsis
Declared in <mp‐units/utility/safe_int.h>
template<
/* implementation-defined */ T,
OverflowPolicy EP = safe_int_throw_policy>
class safe_int;
Description
This class wraps any integral type and models all requirements for mp‐units representation types (RealScalar, UnitMagnitudeScalable, etc.). Every arithmetic operation checks for overflow and delegates to the ErrorPolicy::on_overflow() handler on detection.
Type Aliases
Name |
Description |
The |
|
The underlying integral type |
Member Functions
Name |
Description |
|
Constructors |
Replaces the wrapped value with its remainder after division by |
|
Multiplies the wrapped value by |
|
Returns a copy of the wrapped value, promoted as |
|
Increment operators |
|
Adds |
|
Returns the negation of the wrapped value, reacting to |
|
Decrement operators |
|
Subtracts |
|
Divides the wrapped value by |
|
Returns the wrapped value. |
|
Converts to the wrapped value. |
Data Members
Name |
Description |
The wrapped value. |
Deduction Guides
Name |
Description |
Deduces |
Friends
Name |
Description |
Streams a safe_int's wrapped value to an output stream |
|
Compares a safe_int with a constrained value |
|
Checks whether a safe_int and a constrained value are equal |
|
Divides a safe_int by a non‐integral constrained value |
|
Divides a non‐integral constrained value by a safe_int |
|
Multiplies a safe_int by a non‐integral constrained value |
|
Multiplies a non‐integral constrained value by a safe_int |
|
Subtracts a non‐integral constrained value from a safe_int |
|
Subtracts a safe_int from a non‐integral constrained value |
|
Adds a non‐integral constrained value to a safe_int |
|
Adds a safe_int to a non‐integral constrained value |
|
Computes the remainder of dividing a safe_int by a constrained value |
|
Computes the remainder of dividing a constrained value by a safe_int |
|
Divides a safe_int by a constrained value |
|
Divides a constrained value by a safe_int |
|
Multiplies a safe_int by a constrained value |
|
Multiplies a constrained value by a safe_int |
|
Subtracts a constrained value from a safe_int |
|
Subtracts a safe_int from a constrained value |
|
Adds a safe_int to a constrained value |
|
Adds a constrained value to a safe_int |
|
Compares a |
|
Checks whether a |
|
Divides a floating‐point value by a |
|
Divides a |
|
Multiplies a floating‐point value by a |
|
Multiplies a |
|
Subtracts a |
|
Subtracts a floating‐point value from a |
|
Adds a |
|
Adds a floating‐point value to a |
|
Compares a |
|
Checks whether a |
|
Computes the remainder of dividing an integral scalar by a |
|
Computes the remainder of dividing a |
|
Divides an integral scalar by a |
|
Divides a |
|
Multiplies an integral scalar by a |
|
Multiplies a |
|
Subtracts a |
|
Subtracts an integral scalar from a |
|
Adds a |
|
Adds an integral scalar to a |
|
Compares two |
|
Checks whether two |
|
Computes the remainder of dividing |
|
Computes the quotient of dividing |
|
Computes the product of |
|
Computes the difference of |
|
Computes the sum of |
Template Parameters
Name |
Description |
T |
the underlying integral type (e.g. int, long, uint32_t) |
ErrorPolicy |
how to react to overflow — default: safe_int_throw_policy on hosted, safe_int_terminate_policy on freestanding |
Created with MrDocs