Wraps an integral type with overflow detection.
<mp-units/safe_int.h>template<
std::integral T,
OverflowPolicy EP = safe_int_throw_policy>
class safe_int;
This class wraps any integral type and models all requirements for mp-units representation types (RealScalar, MagnitudeScalable, etc.). Every arithmetic operation checks for overflow and delegates to the ErrorPolicy::on_overflow() handler on detection.
| Name |
|---|
error_policy |
value_type |
| Name | Description |
|---|---|
safe_int [constructor] | Constructors |
operator%= | Modulus assignment operator |
operator*= | Multiplication assignment operator |
operator+ | Unary plus operator |
operator++ | Increment operators |
operator+= | Addition assignment operator |
operator- | Unary minus operator |
operator-- | Decrement operators |
operator-= | Subtraction assignment operator |
operator/= | Division assignment operator |
value | |
operator T | Conversion to T |
| Name |
|---|
value_ |
| Name | Description |
|---|---|
operator<< |
Stream insertion operator |
| 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 |