mp_units::check_in_range¶
Policy that tests whether the value lies between min and max.
Synopsis¶
Declared in <mp-units/overflow_policies.h>
template<
/* implementation-defined */ Lo,
/* implementation-defined */ Hi>
struct check_in_range;
Description¶
Each end is included unless it is given as exclusive_bound.
A checking policy, so the value is stored unchanged. When the representation has a constraint_violation_handler specialization, the library calls its on_violation() for a rejected value in every build mode. Otherwise, a rejected value violates the precondition of the operation that stores it.
Example:
{cpp}
// With constrained<double, throw_policy> rep → throws std::domain_error on violation
// With plain double rep → a value outside [-90°, 90°] violates a precondition
inline constexpr struct equator :
absolute_point_origin<geo_latitude, check_in_range{-90 * deg, 90 * deg}> {} equator;
Member Functions¶
| Name | Description |
|---|---|
operator() | Tells whether v lies between min and max, each included unless given as exclusive_bound. Returns false for NaN. |