Skip to content

mp_units::quantity_point::is_within_bounds

Tells whether constructing quantity_point{q, po} would pass the bounds of the point's origin.

Synopsis

Declared in <mp-units/framework/quantity_point.h>

template<typename FwdQ, QuantityOf<quantity_spec> Q = std::remove_cvref_t<FwdQ>>
  requires(detail::bounds_exact_in<PO, quantity_type>()) && (detail::enforced_bounds_check<PO, quantity_type>()) &&
          std::constructible_from<quantity_type, FwdQ>
[[nodiscard]] constexpr static bool is_within_bounds(FwdQ&& q, decltype(PO));

Description

q is converted to quantity_type and passed to the bool operator() of the bounds policy that construction enforces. That is the policy of point_origin or, for a relative origin without bounds of its own, the policy of its nearest bounded ancestor, with q translated into that ancestor's frame. Origins further up are not tested, and construction does not apply their policies either. The compile-time nesting check places the enforced bounds within theirs, up to rounding of floating-point offsets. No point is constructed, so a rejected value neither calls the representation's violation handler nor violates a precondition.

Offered when the enforced bounds policy is a checking policy, such as check_in_range, check_non_negative, or a user-defined policy whose operator() returns bool. Also offered when the point has no bounds, where it always returns true.

Return Value

Note

The return value should not be discarded.

See Also

try_make for the same test returning the constructed point