Wraps an integral type with overflow detection.
Synopsis
Declared in <mp‐units/safe_int.h>
template<
std::integral 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, MagnitudeScalable, etc.). Every arithmetic operation checks for overflow and delegates to the ErrorPolicy::on_overflow() handler on detection.
Types
Member Functions
Name |
Description |
|
Constructors |
Modulus assignment operator |
|
Multiplication assignment operator |
|
Unary plus operator |
|
Increment operators |
|
Addition assignment operator |
|
Unary minus operator |
|
Decrement operators |
|
Subtraction assignment operator |
|
Division assignment operator |
|
Conversion to |
Data Members
Name |
Friends
| Name | Description |
|---|---|
Stream insertion operator |
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