[#mp_units-utility-constrained] = xref:mp_units.adoc[mp_units]::xref:mp_units/utility.adoc[utility]::constrained :relfileprefix: ../../ :mrdocs: A transparent wrapper that carries an error policy for domain constraint enforcement. == Synopsis Declared in `<mp‐units/utility/constrained.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename T, xref:mp_units/utility/ConstraintPolicy.adoc[ConstraintPolicy] ErrorPolicy = xref:mp_units/utility/throw_policy.adoc[throw_policy]> class constrained; ---- == Description This wrapper does not check anything itself. It serves as a signal to the mp‐units library that domain constraint violations should be reported via the ErrorPolicy rather than through precondition checks. All arithmetic operations are forwarded to the underlying type T. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:mp_units/utility/constrained/error_policy.adoc[`error_policy`] | The policy used to report domain constraint violations | xref:mp_units/utility/constrained/value_type.adoc[`value_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%=`] | Assigns the wrapped value to its remainder with respect to `rhs.` | xref:mp_units/utility/constrained/operator_star_eq.adoc[`operator*=`] | Multiplies the wrapped value by `rhs.` | xref:mp_units/utility/constrained/operator_inc-0e.adoc[`operator++`] | Increment operators | xref:mp_units/utility/constrained/operator_plus_eq.adoc[`operator+=`] | Adds `rhs` to the wrapped value. | xref:mp_units/utility/constrained/operator_dec-0d4.adoc[`operator‐‐`] | Decrement operators | xref:mp_units/utility/constrained/operator_minus_eq.adoc[`operator‐=`] | Subtracts `rhs` from the wrapped value. | xref:mp_units/utility/constrained/operator_slash_eq.adoc[`operator/=`] | Divides the wrapped value by `rhs.` | xref:mp_units/utility/constrained/value.adoc[`value`] | The wrapped underlying value. | xref:mp_units/utility/constrained/2conversion.adoc[`operator T`] | Implicitly converts back to the underlying representation type. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:mp_units/utility/constrained/value_.adoc[`value_`] | The wrapped underlying value |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:mp_units/utility/operator_minus-0d1.adoc[mp_units::utility::operator‐]` | Negates the wrapped value | `xref:mp_units/utility/operator_plus-0c.adoc[mp_units::utility::operator+]` | Applies unary `+` 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_int | xref:mp_units/utility/operator_star-0b.adoc[`operator*`] | Multiplies a constrained value by a safe_int | xref:mp_units/utility/operator_star-0e4.adoc[`operator*`] | Multiplies a safe_int by a non‐integral constrained value | xref:mp_units/utility/operator_star-0e8.adoc[`operator*`] | Multiplies a non‐integral constrained value by a safe_int | xref:mp_units/utility/operator_plus-02.adoc[`operator+`] | Adds a constrained value to a safe_int | xref:mp_units/utility/operator_plus-06b.adoc[`operator+`] | Adds a safe_int to a non‐integral constrained value | xref:mp_units/utility/operator_plus-0fe8.adoc[`operator+`] | Adds a non‐integral constrained value to a safe_int | xref:mp_units/utility/operator_minus-01.adoc[`operator‐`] | Subtracts a safe_int from a non‐integral constrained value | xref:mp_units/utility/operator_minus-05.adoc[`operator‐`] | Subtracts a safe_int from a constrained value | xref:mp_units/utility/operator_minus-07.adoc[`operator‐`] | Subtracts a non‐integral constrained value from a safe_int | xref:mp_units/utility/operator_slash-04.adoc[`operator/`] | Divides a non‐integral constrained value by a safe_int | xref:mp_units/utility/operator_slash-082.adoc[`operator/`] | Divides a safe_int by a non‐integral constrained value | xref:mp_units/utility/operator_slash-08b.adoc[`operator/`] | Divides a constrained value by a safe_int |=== == Template Parameters [cols="1,4"] |=== | Name| Description | *T* | the underlying representation type | *ErrorPolicy* | policy type satisfying ConstraintPolicy (provides static on_constraint_violation(std::string_view)) |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#