mp_units::quantity_point::try_make¶
Constructs quantity_point{q, po}, or returns bounds_violation for a value that is_within_bounds rejects.
Synopsis¶
Declared in <mp-units/framework/quantity_point.h>
template<typename FwdQ>
requires requires(const FwdQ& q) { is_within_bounds(q, PO); } &&
std::constructible_from<quantity_point, FwdQ, decltype(PO)>
[[nodiscard]] constexpr static std::expected<quantity_point, bounds_violation> try_make(FwdQ&& q, decltype(PO) po);
Description¶
Written only in terms of is_within_bounds and the constructor, so a rejected value is not passed to the constructor. This makes it the wide-contract alternative to the constructor, whose precondition such a value violates when the representation has no constraint_violation_handler. The same function can be written over std::optional or another error type. Available where <expected> is.
Return Value¶
Note
The return value should not be discarded.
See Also¶
is_within_bounds for the test alone