Policy that checks the value is within [min, max]and reports violations.
If the quantity's representation type has a constraint_violation_handler specialization, the handler's on_violation() is called on out-of-bounds values (providing guaranteed enforcement regardless of build mode). Otherwise, falls back to MP_UNITS_PRECONDITION, which may be disabled in release builds.
Example:
{cpp}
// With constrained<double, throw_policy> rep → throws std::domain_error on violation
// With plain double rep → asserts via MP_UNITS_PRECONDITION (may be no-op in release)
inline constexpr struct equator :
absolute_point_origin<geo_latitude, check_in_range{-90 * deg, 90 * deg}> {} equator;
| Name | Description |
|---|---|
operator() | Checks that v lies within [min, max]and reports a violation otherwise. |
| Name | Description |
|---|---|
max | The upper boundary of the allowed range |
min | The lower boundary of the allowed range |