[#mp_units-utility-constrained]
= xref:mp_units.adoc[mp&lowbar;units]::xref:mp_units/utility.adoc[utility]::constrained
:relfileprefix: ../../
:mrdocs:

A transparent wrapper that carries an error policy for domain constraint enforcement&period;

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;utility&sol;constrained&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename T,
    xref:mp_units/utility/ConstraintPolicy.adoc[ConstraintPolicy] ErrorPolicy = xref:mp_units/utility/throw_policy.adoc[throw&lowbar;policy]&gt;
class constrained;
----

== Description

This wrapper does not check anything itself&period; It serves as a signal to the mp&hyphen;units library that domain constraint violations should be reported via the ErrorPolicy rather than through precondition checks&period;

All arithmetic operations are forwarded to the underlying type T&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:mp_units/utility/constrained/error_policy.adoc[`error&lowbar;policy`] 
| The policy used to report domain constraint violations
| xref:mp_units/utility/constrained/value_type.adoc[`value&lowbar;type`] 
| The underlying representation type
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:mp_units/utility/constrained/2constructor-0742.adoc[`constrained`]         [.small]#[constructor]#
| Constructors
| xref:mp_units/utility/constrained/operator_mod_eq.adoc[`operator%&equals;`] 
| Assigns the wrapped value to its remainder with respect to `rhs&period;`
| xref:mp_units/utility/constrained/operator_star_eq.adoc[`operator&ast;&equals;`] 
| Multiplies the wrapped value by `rhs&period;`
| xref:mp_units/utility/constrained/operator_inc-0e.adoc[`operator&plus;&plus;`] 
| Increment operators
| xref:mp_units/utility/constrained/operator_plus_eq.adoc[`operator&plus;&equals;`] 
| Adds `rhs` to the wrapped value&period;
| xref:mp_units/utility/constrained/operator_dec-0d4.adoc[`operator&hyphen;&hyphen;`] 
| Decrement operators
| xref:mp_units/utility/constrained/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Subtracts `rhs` from the wrapped value&period;
| xref:mp_units/utility/constrained/operator_slash_eq.adoc[`operator&sol;&equals;`] 
| Divides the wrapped value by `rhs&period;`
| xref:mp_units/utility/constrained/value.adoc[`value`] 
| The wrapped underlying value&period;
| xref:mp_units/utility/constrained/2conversion.adoc[`operator T`] 
| Implicitly converts back to the underlying representation type&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:mp_units/utility/constrained/value_.adoc[`value&lowbar;`] 
| The wrapped underlying value
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:mp_units/utility/operator_minus-0d1.adoc[mp&lowbar;units::utility::operator&hyphen;]`
| Negates the wrapped value
| `xref:mp_units/utility/operator_plus-0c.adoc[mp&lowbar;units::utility::operator&plus;]`
| Applies unary `&plus;` to the wrapped value
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:mp_units/utility/operator_mod-0e.adoc[`operator%`]
| Computes the remainder of dividing a constrained value by a safe&lowbar;int
| xref:mp_units/utility/operator_star-0b.adoc[`operator&ast;`]
| Multiplies a constrained value by a safe&lowbar;int
| xref:mp_units/utility/operator_star-0e4.adoc[`operator&ast;`]
| Multiplies a safe&lowbar;int by a non&hyphen;integral constrained value
| xref:mp_units/utility/operator_star-0e8.adoc[`operator&ast;`]
| Multiplies a non&hyphen;integral constrained value by a safe&lowbar;int
| xref:mp_units/utility/operator_plus-02.adoc[`operator&plus;`]
| Adds a constrained value to a safe&lowbar;int
| xref:mp_units/utility/operator_plus-06b.adoc[`operator&plus;`]
| Adds a safe&lowbar;int to a non&hyphen;integral constrained value
| xref:mp_units/utility/operator_plus-0fe8.adoc[`operator&plus;`]
| Adds a non&hyphen;integral constrained value to a safe&lowbar;int
| xref:mp_units/utility/operator_minus-01.adoc[`operator&hyphen;`]
| Subtracts a safe&lowbar;int from a non&hyphen;integral constrained value
| xref:mp_units/utility/operator_minus-05.adoc[`operator&hyphen;`]
| Subtracts a safe&lowbar;int from a constrained value
| xref:mp_units/utility/operator_minus-07.adoc[`operator&hyphen;`]
| Subtracts a non&hyphen;integral constrained value from a safe&lowbar;int
| xref:mp_units/utility/operator_slash-04.adoc[`operator&sol;`]
| Divides a non&hyphen;integral constrained value by a safe&lowbar;int
| xref:mp_units/utility/operator_slash-082.adoc[`operator&sol;`]
| Divides a safe&lowbar;int by a non&hyphen;integral constrained value
| xref:mp_units/utility/operator_slash-08b.adoc[`operator&sol;`]
| Divides a constrained value by a safe&lowbar;int
|===

== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *T*
| the underlying representation type
| *ErrorPolicy*
| policy type satisfying ConstraintPolicy (provides static on&lowbar;constraint&lowbar;violation(std&colon;&colon;string&lowbar;view))
|===


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