feat: representation type template parameter added to value convertion functions
Resolves #588
This commit is contained in:
1 parent
5903e5661f
commit
2cff579650
5 files changed
+112
-20
No files matched your search
@@ -199,6 +199,20 @@ public:
|
||||
return quantity<detail::make_reference(quantity_spec, ToU{}), Rep>{*this};
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep>
|
||||
requires detail::QuantityConvertibleTo<quantity, quantity<reference, ToRep>>
|
||||
[[nodiscard]] constexpr QuantityOf<quantity_spec> auto in() const
|
||||
{
|
||||
return quantity<reference, ToRep>{*this};
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep, detail::UnitCompatibleWith<unit, quantity_spec> ToU>
|
||||
requires detail::QuantityConvertibleTo<quantity, quantity<detail::make_reference(quantity_spec, ToU{}), ToRep>>
|
||||
[[nodiscard]] constexpr QuantityOf<quantity_spec> auto in(ToU) const
|
||||
{
|
||||
return quantity<detail::make_reference(quantity_spec, ToU{}), ToRep>{*this};
|
||||
}
|
||||
|
||||
template<detail::UnitCompatibleWith<unit, quantity_spec> ToU>
|
||||
requires requires(quantity q) { value_cast<ToU{}>(q); }
|
||||
[[nodiscard]] constexpr QuantityOf<quantity_spec> auto force_in(ToU) const
|
||||
@@ -206,6 +220,20 @@ public:
|
||||
return value_cast<ToU{}>(*this);
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep>
|
||||
requires requires(quantity q) { value_cast<ToRep>(q); }
|
||||
[[nodiscard]] constexpr QuantityOf<quantity_spec> auto force_in() const
|
||||
{
|
||||
return value_cast<ToRep>(*this);
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep, detail::UnitCompatibleWith<unit, quantity_spec> ToU>
|
||||
requires requires(quantity q) { value_cast<ToU{}, ToRep>(q); }
|
||||
[[nodiscard]] constexpr QuantityOf<quantity_spec> auto force_in(ToU) const
|
||||
{
|
||||
return value_cast<ToU{}, ToRep>(*this);
|
||||
}
|
||||
|
||||
// data access
|
||||
template<Unit U>
|
||||
requires(U{} == unit)
|
||||
|
||||
@@ -284,6 +284,20 @@ public:
|
||||
return ::mp_units::quantity_point{quantity_ref_from(PO).in(ToU{}), PO};
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep>
|
||||
requires detail::QuantityConvertibleTo<quantity_type, quantity<reference, ToRep>>
|
||||
[[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto in() const
|
||||
{
|
||||
return ::mp_units::quantity_point{quantity_ref_from(PO).template in<ToRep>(), PO};
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep, detail::UnitCompatibleWith<unit, quantity_spec> ToU>
|
||||
requires detail::QuantityConvertibleTo<quantity_type, quantity<detail::make_reference(quantity_spec, ToU{}), ToRep>>
|
||||
[[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto in(ToU) const
|
||||
{
|
||||
return ::mp_units::quantity_point{quantity_ref_from(PO).template in<ToRep>(ToU{}), PO};
|
||||
}
|
||||
|
||||
template<detail::UnitCompatibleWith<unit, quantity_spec> ToU>
|
||||
requires requires(quantity_type q) { value_cast<ToU{}>(q); }
|
||||
[[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto force_in(ToU) const
|
||||
@@ -291,6 +305,20 @@ public:
|
||||
return ::mp_units::quantity_point{quantity_ref_from(PO).force_in(ToU{}), PO};
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep>
|
||||
requires requires(quantity_type q) { value_cast<ToRep>(q); }
|
||||
[[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto force_in() const
|
||||
{
|
||||
return ::mp_units::quantity_point{quantity_ref_from(PO).template force_in<ToRep>(), PO};
|
||||
}
|
||||
|
||||
template<RepresentationOf<get_quantity_spec(R).character> ToRep, detail::UnitCompatibleWith<unit, quantity_spec> ToU>
|
||||
requires requires(quantity_type q) { value_cast<ToU{}, ToRep>(q); }
|
||||
[[nodiscard]] constexpr QuantityPointOf<quantity_spec> auto force_in(ToU) const
|
||||
{
|
||||
return ::mp_units::quantity_point{quantity_ref_from(PO).template force_in<ToRep>(ToU{}), PO};
|
||||
}
|
||||
|
||||
// conversion operators
|
||||
template<typename QP_, QuantityPointLike QP = std::remove_cvref_t<QP_>>
|
||||
requires(point_origin == quantity_point_like_traits<QP>::point_origin) &&
|
||||
|
||||
Reference in new issue
Block a user