[#mp_units-safe_int-09] = xref:mp_units.adoc[mp_units]::safe_int :relfileprefix: ../ :mrdocs: Wraps an integral type with overflow detection. == Synopsis Declared in `<mp‐units/safe_int.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< std::integral T, xref:mp_units/OverflowPolicy.adoc[OverflowPolicy] EP = xref:mp_units/safe_int_throw_policy.adoc[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 [cols=1] |=== | Name | xref:mp_units/safe_int-09/error_policy.adoc[`error_policy`] | xref:mp_units/safe_int-09/value_type.adoc[`value_type`] |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:mp_units/safe_int-09/2constructor-06.adoc[`safe_int`] [.small]#[constructor]# | Constructors | xref:mp_units/safe_int-09/operator_mod_eq.adoc[`operator%=`] | Modulus assignment operator | xref:mp_units/safe_int-09/operator_star_eq.adoc[`operator*=`] | Multiplication assignment operator | xref:mp_units/safe_int-09/operator_plus.adoc[`operator+`] | Unary plus operator | xref:mp_units/safe_int-09/operator_inc-01.adoc[`operator++`] | Increment operators | xref:mp_units/safe_int-09/operator_plus_eq.adoc[`operator+=`] | Addition assignment operator | xref:mp_units/safe_int-09/operator_minus.adoc[`operator‐`] | Unary minus operator | xref:mp_units/safe_int-09/operator_dec-0c.adoc[`operator‐‐`] | Decrement operators | xref:mp_units/safe_int-09/operator_minus_eq.adoc[`operator‐=`] | Subtraction assignment operator | xref:mp_units/safe_int-09/operator_slash_eq.adoc[`operator/=`] | Division assignment operator | xref:mp_units/safe_int-09/value.adoc[`value`] | | xref:mp_units/safe_int-09/2conversion.adoc[`operator T`] | Conversion to `T` |=== == Data Members [cols=1] |=== | Name | xref:mp_units/safe_int-09/value_.adoc[`value_`] |=== == Friends [cols="1,4"] |=== |Name|Description | `xref:mp_units/operator_lshift-06.adoc[mp_units::operator<<]` | Stream insertion operator |=== == Template Parameters [cols="1,4"] |=== |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 |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#