mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
refactor: now we have only one quantity_point
converting constructor
This commit is contained in:
@@ -112,18 +112,20 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<auto R2, typename Rep2>
|
|
||||||
requires std::constructible_from<quantity_type, quantity<R2, Rep2>>
|
|
||||||
constexpr explicit(!std::convertible_to<quantity<R2, Rep2>, quantity_type>)
|
|
||||||
quantity_point(const quantity_point<R2, point_origin, Rep2>& qp) :
|
|
||||||
q_(qp.relative())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<QuantityPointOf<absolute_point_origin> QP>
|
template<QuantityPointOf<absolute_point_origin> QP>
|
||||||
requires std::constructible_from<quantity_type, typename QP::quantity_type>
|
requires std::constructible_from<quantity_type, typename QP::quantity_type>
|
||||||
constexpr explicit(!std::convertible_to<typename QP::quantity_type, quantity_type>) quantity_point(const QP& qp) :
|
constexpr explicit(!std::convertible_to<typename QP::quantity_type, quantity_type>) quantity_point(const QP& qp) :
|
||||||
q_(qp.absolute() - zero().absolute())
|
q_([&] {
|
||||||
|
if constexpr (std::is_same_v<std::remove_const_t<decltype(point_origin)>,
|
||||||
|
std::remove_const_t<decltype(QP::point_origin)>>) {
|
||||||
|
return qp.relative();
|
||||||
|
} else if constexpr (detail::is_derived_from_specialization_of_relative_point_origin<
|
||||||
|
std::remove_const_t<decltype(point_origin)>>) {
|
||||||
|
return qp.absolute() - zero().absolute();
|
||||||
|
} else {
|
||||||
|
return qp.absolute();
|
||||||
|
}
|
||||||
|
}())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user