mp_units::quantity_point::try_make¶
Constructs quantity_point{q, po}, or returns bounds_violation for a value that is_within_bounds rejects. The overload without an origin takes a quantity at the default origin, and the overload taking a point of another type or a point-like value constructs quantity_point{qp}.
Synopses¶
Declared in <mp-units/framework/quantity_point.h>
template<typename QP>
requires(QuantityPoint<QP> || detail::QuantityPointLike<QP>) &&
requires(const QP& qp) { is_within_bounds(qp); }
[[nodiscard]] constexpr static std::expected<quantity_point, bounds_violation> try_make(
QP const& qp);
template<typename FwdQ, QuantityOf<quantity_spec> Q = std::remove_cvref_t<FwdQ>>
requires requires(const FwdQ& q) { is_within_bounds(q); } &&
std::constructible_from<quantity_point, FwdQ>
[[nodiscard]] constexpr static std::expected<quantity_point, bounds_violation> try_make(
FwdQ&& q);
Constructs quantity_point{q, po}, or returns bounds_violation for a value that is_within_bounds rejects. The overload without an origin takes a quantity at the default origin, and the overload taking a point of another type or a point-like value constructs quantity_point{qp}.
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));
Return Value¶
Note
The return value should not be discarded.
See Also¶
is_within_boundsfor the test alone