[#mp_units-safe_int-09]
= xref:mp_units.adoc[mp&lowbar;units]::safe&lowbar;int
:relfileprefix: ../
:mrdocs:

Wraps an integral type with overflow detection&period;

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;safe&lowbar;int&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    &sol;&ast; implementation-defined &ast;&sol; T,
    xref:mp_units/OverflowPolicy.adoc[OverflowPolicy] EP = xref:mp_units/safe_int_throw_policy.adoc[safe&lowbar;int&lowbar;throw&lowbar;policy]&gt;
class safe&lowbar;int;
----

== Description

This class wraps any integral type and models all requirements for mp&hyphen;units representation types (RealScalar, MagnitudeScalable, etc&period;)&period; Every arithmetic operation checks for overflow and delegates to the ErrorPolicy&colon;&colon;on&lowbar;overflow() handler on detection&period;

== Type Aliases

[cols="1"]
|===
| Name
| xref:mp_units/safe_int-09/error_policy.adoc[`error&lowbar;policy`] 
| xref:mp_units/safe_int-09/value_type.adoc[`value&lowbar;type`] 
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:mp_units/safe_int-09/2constructor-06.adoc[`safe&lowbar;int`]         [.small]#[constructor]#
| Constructors
| xref:mp_units/safe_int-09/operator_mod_eq.adoc[`operator%&equals;`] 
| Modulus assignment operator
| xref:mp_units/safe_int-09/operator_star_eq.adoc[`operator&ast;&equals;`] 
| Multiplication assignment operator
| xref:mp_units/safe_int-09/operator_plus.adoc[`operator&plus;`] 
| Unary plus operator
| xref:mp_units/safe_int-09/operator_inc-01.adoc[`operator&plus;&plus;`] 
| Increment operators
| xref:mp_units/safe_int-09/operator_plus_eq.adoc[`operator&plus;&equals;`] 
| Addition assignment operator
| xref:mp_units/safe_int-09/operator_minus.adoc[`operator&hyphen;`] 
| Unary minus operator
| xref:mp_units/safe_int-09/operator_dec-0c.adoc[`operator&hyphen;&hyphen;`] 
| Decrement operators
| xref:mp_units/safe_int-09/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Subtraction assignment operator
| xref:mp_units/safe_int-09/operator_slash_eq.adoc[`operator&sol;&equals;`] 
| 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&lowbar;`] 
|===


== Deduction Guides

[cols="1"]
|===
| Name
| xref:mp_units/safe_int-0b.adoc[`safe&lowbar;int&lt;T&gt;`] 
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:mp_units/operator_lshift-05.adoc[mp&lowbar;units::operator&lt;&lt;]`
| Stream insertion operator
| `xref:mp_units/operator_3way-0c.adoc[mp&lowbar;units::operator&lt;&equals;&gt;]`
| Three&hyphen;way comparison operator
| `xref:mp_units/operator_eq-0f.adoc[mp&lowbar;units::operator&equals;&equals;]`
| Equality operator
| `xref:mp_units/operator_slash-0e1.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_slash-0a5.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_star-0c6.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_star-05e.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_minus-05.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_minus-06.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_plus-08a.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
| `xref:mp_units/operator_plus-0203.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
| `xref:mp_units/operator_mod-0f.adoc[mp&lowbar;units::operator%]`
| Modulus operator
| `xref:mp_units/operator_mod-09.adoc[mp&lowbar;units::operator%]`
| Modulus operator
| `xref:mp_units/operator_slash-09.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_slash-01.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_star-0ce.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_star-09.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_minus-04.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_minus-09.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_plus-088.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
| `xref:mp_units/operator_plus-065.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
| `xref:mp_units/operator_3way-00.adoc[mp&lowbar;units::operator&lt;&equals;&gt;]`
| Three&hyphen;way comparison operator
| `xref:mp_units/operator_eq-04.adoc[mp&lowbar;units::operator&equals;&equals;]`
| Equality operator
| `xref:mp_units/operator_slash-0f4.adoc[mp&lowbar;units::operator&sol;]`
| 
| `xref:mp_units/operator_slash-0fb.adoc[mp&lowbar;units::operator&sol;]`
| 
| `xref:mp_units/operator_star-05f.adoc[mp&lowbar;units::operator&ast;]`
| 
| `xref:mp_units/operator_star-006.adoc[mp&lowbar;units::operator&ast;]`
| 
| `xref:mp_units/operator_minus-0f.adoc[mp&lowbar;units::operator&hyphen;]`
| 
| `xref:mp_units/operator_minus-0ca.adoc[mp&lowbar;units::operator&hyphen;]`
| 
| `xref:mp_units/operator_plus-04.adoc[mp&lowbar;units::operator&plus;]`
| 
| `xref:mp_units/operator_plus-0c.adoc[mp&lowbar;units::operator&plus;]`
| 
| `xref:mp_units/operator_3way-04.adoc[mp&lowbar;units::operator&lt;&equals;&gt;]`
| Three&hyphen;way comparison operator
| `xref:mp_units/operator_eq-094.adoc[mp&lowbar;units::operator&equals;&equals;]`
| Equality operator
| `xref:mp_units/operator_mod-05.adoc[mp&lowbar;units::operator%]`
| Modulus operator
| `xref:mp_units/operator_mod-01a.adoc[mp&lowbar;units::operator%]`
| Modulus operator
| `xref:mp_units/operator_slash-05.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_slash-0b2.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_star-054.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_star-013.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_minus-01.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_minus-07.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_plus-0204.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
| `xref:mp_units/operator_plus-0b.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
| `xref:mp_units/operator_3way-0dc.adoc[mp&lowbar;units::operator&lt;&equals;&gt;]`
| Three&hyphen;way comparison operator
| `xref:mp_units/operator_eq-09a.adoc[mp&lowbar;units::operator&equals;&equals;]`
| Equality operator
| `xref:mp_units/operator_mod-0e.adoc[mp&lowbar;units::operator%]`
| Modulus operator
| `xref:mp_units/operator_slash-0f1.adoc[mp&lowbar;units::operator&sol;]`
| Division operator
| `xref:mp_units/operator_star-072.adoc[mp&lowbar;units::operator&ast;]`
| Multiplication operator
| `xref:mp_units/operator_minus-00.adoc[mp&lowbar;units::operator&hyphen;]`
| Subtraction operator
| `xref:mp_units/operator_plus-062.adoc[mp&lowbar;units::operator&plus;]`
| Addition operator
|===

== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *T*
| the underlying integral type (e&period;g&period; int, long, uint32&lowbar;t)
| *ErrorPolicy*
| how to react to overflow — default&colon; safe&lowbar;int&lowbar;throw&lowbar;policy on hosted, safe&lowbar;int&lowbar;terminate&lowbar;policy on freestanding
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
