Policy that checks the value is within [min, max]and reports violations.

Synopsis

Declared in <mp‐units/overflow_policies.h>

template<Quantity Q>
struct check_in_range;

Description

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_EXPECTS, 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_EXPECTS (may be no-op in release)
 template<>
 constexpr auto quantity_bounds<equator> = check_in_range{-90 * deg, 90 * deg};

Member Functions

Name

operator()

Data Members

Name

max

min

Created with MrDocs