A transparent wrapper that carries an error policy for domain constraint enforcement.
Declared in <mp-units/utility/constrained.h>
template<
typename T,
ConstraintPolicy ErrorPolicy = throw_policy>
class constrained;
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.
| Name | Description |
|---|---|
error_policy | The policy used to report domain constraint violations |
value_type | The underlying representation type |
| Name | Description |
|---|---|
constrained [constructor] | Constructors |
operator%= | Assigns the wrapped value to its remainder with respect to rhs. |
operator*= | Multiplies the wrapped value by rhs. |
operator++ | Increment operators |
operator+= | Adds rhs to the wrapped value. |
operator-- | Decrement operators |
operator-= | Subtracts rhs from the wrapped value. |
operator/= | Divides the wrapped value by rhs. |
value | The wrapped underlying value. |
operator T | Implicitly converts back to the underlying representation type. |
| Name | Description |
|---|---|
value_ | The wrapped underlying value |
| Name | Description |
|---|---|
mp_units::utility::operator- | Negates the wrapped value |
mp_units::utility::operator+ | Applies unary + to the wrapped value |
| Name | Description |
|---|---|
operator% | Computes the remainder of dividing a constrained value by a safe_int |
operator* | Multiplies a constrained value by a safe_int |
operator* | Multiplies a safe_int by a non-integral constrained value |
operator* | Multiplies a non-integral constrained value by a safe_int |
operator+ | Adds a constrained value to a safe_int |
operator+ | Adds a safe_int to a non-integral constrained value |
operator+ | Adds a non-integral constrained value to a safe_int |
operator- | Subtracts a safe_int from a non-integral constrained value |
operator- | Subtracts a safe_int from a constrained value |
operator- | Subtracts a non-integral constrained value from a safe_int |
operator/ | Divides a non-integral constrained value by a safe_int |
operator/ | Divides a safe_int by a non-integral constrained value |
operator/ | Divides a constrained value by a safe_int |
| Name | Description |
|---|---|
| T | the underlying representation type |
| ErrorPolicy | policy type satisfying ConstraintPolicy (provides static on_constraint_violation(std::string_view)) |