Wraps an integral type with overflow detection.

Synopsis

Declared in <mp‐units/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, MagnitudeScalable, etc.). Every arithmetic operation checks for overflow and delegates to the ErrorPolicy::on_overflow() handler on detection.

Types

Member Functions

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

Data Members

Name

value_

Friends

Name Description

mp_units::operator<<

Stream insertion operator

mp_units::operator<=>

Three‐way comparison operator

mp_units::operator==

Equality operator

mp_units::operator/

Division operator

mp_units::operator/

Division operator

mp_units::operator*

Multiplication operator

mp_units::operator*

Multiplication operator

mp_units::operator‐

Subtraction operator

mp_units::operator‐

Subtraction operator

mp_units::operator+

Addition operator

mp_units::operator+

Addition operator

mp_units::operator%

Modulus operator

mp_units::operator%

Modulus operator

mp_units::operator/

Division operator

mp_units::operator/

Division operator

mp_units::operator*

Multiplication operator

mp_units::operator*

Multiplication operator

mp_units::operator‐

Subtraction operator

mp_units::operator‐

Subtraction operator

mp_units::operator+

Addition operator

mp_units::operator+

Addition operator

mp_units::operator<=>

Three‐way comparison operator

mp_units::operator==

Equality operator

mp_units::operator/

mp_units::operator/

mp_units::operator*

mp_units::operator*

mp_units::operator‐

mp_units::operator‐

mp_units::operator+

mp_units::operator+

mp_units::operator<=>

Three‐way comparison operator

mp_units::operator==

Equality operator

mp_units::operator%

Modulus operator

mp_units::operator%

Modulus operator

mp_units::operator/

Division operator

mp_units::operator/

Division operator

mp_units::operator*

Multiplication operator

mp_units::operator*

Multiplication operator

mp_units::operator‐

Subtraction operator

mp_units::operator‐

Subtraction operator

mp_units::operator+

Addition operator

mp_units::operator+

Addition operator

mp_units::operator<=>

Three‐way comparison operator

mp_units::operator==

Equality operator

mp_units::operator%

Modulus operator

mp_units::operator/

Division operator

mp_units::operator*

Multiplication operator

mp_units::operator‐

Subtraction operator

mp_units::operator+

Addition 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