mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 21:24:27 +02:00
Small quantity_point refactoring
This commit is contained in:
@@ -142,14 +142,14 @@ public:
|
|||||||
[[nodiscard]] friend constexpr auto operator<=>(const quantity_point& lhs, const QP& rhs)
|
[[nodiscard]] friend constexpr auto operator<=>(const quantity_point& lhs, const QP& rhs)
|
||||||
requires std::three_way_comparable_with<quantity_type, typename QP::quantity_type>
|
requires std::three_way_comparable_with<quantity_type, typename QP::quantity_type>
|
||||||
{
|
{
|
||||||
return lhs.q_ <=> rhs.relative();
|
return lhs.relative() <=> rhs.relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<QuantityPoint QP>
|
template<QuantityPoint QP>
|
||||||
[[nodiscard]] friend constexpr auto operator==(const quantity_point& lhs, const QP& rhs)
|
[[nodiscard]] friend constexpr bool operator==(const quantity_point& lhs, const QP& rhs)
|
||||||
requires std::equality_comparable_with<quantity_type, typename QP::quantity_type>
|
requires std::equality_comparable_with<quantity_type, typename QP::quantity_type>
|
||||||
{
|
{
|
||||||
return lhs.q_ == rhs.relative();
|
return lhs.relative() == rhs.relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
[[nodiscard]] friend constexpr bool operator==(const quantity_point& lhs, const QP& rhs)
|
[[nodiscard]] friend constexpr bool operator==(const quantity_point& lhs, const QP& rhs)
|
||||||
requires std::equality_comparable_with<quantity_type, typename QP::quantity_type>
|
requires std::equality_comparable_with<quantity_type, typename QP::quantity_type>
|
||||||
{
|
{
|
||||||
return lhs.q_ == rhs.relative();
|
return lhs.relative() == rhs.relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<QuantityPoint QP>
|
template<QuantityPoint QP>
|
||||||
@@ -172,7 +172,7 @@ public:
|
|||||||
[[nodiscard]] friend constexpr bool operator<(const quantity_point& lhs, const QP& rhs)
|
[[nodiscard]] friend constexpr bool operator<(const quantity_point& lhs, const QP& rhs)
|
||||||
requires std::totally_ordered_with<quantity_type, typename QP::quantity_type>
|
requires std::totally_ordered_with<quantity_type, typename QP::quantity_type>
|
||||||
{
|
{
|
||||||
return lhs.q_ < rhs.relative();
|
return lhs.relative() < rhs.relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<QuantityPoint QP>
|
template<QuantityPoint QP>
|
||||||
@@ -202,19 +202,19 @@ public:
|
|||||||
template<typename D, typename U, typename Rep>
|
template<typename D, typename U, typename Rep>
|
||||||
quantity_point(quantity<D, U, Rep>) -> quantity_point<D, U, Rep>;
|
quantity_point(quantity<D, U, Rep>) -> quantity_point<D, U, Rep>;
|
||||||
|
|
||||||
constexpr QuantityPoint AUTO operator+(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs)
|
[[nodiscard]] constexpr QuantityPoint AUTO operator+(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs)
|
||||||
requires requires { lhs.relative() + rhs; }
|
requires requires { lhs.relative() + rhs; }
|
||||||
{
|
{
|
||||||
return quantity_point(lhs.relative() + rhs);
|
return quantity_point(lhs.relative() + rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr QuantityPoint AUTO operator+(const Quantity AUTO& lhs, const QuantityPoint AUTO& rhs)
|
[[nodiscard]] constexpr QuantityPoint AUTO operator+(const Quantity AUTO& lhs, const QuantityPoint AUTO& rhs)
|
||||||
requires requires { rhs + lhs; }
|
requires requires { rhs + lhs; }
|
||||||
{
|
{
|
||||||
return rhs + lhs;
|
return rhs + lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr QuantityPoint AUTO operator-(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs)
|
[[nodiscard]] constexpr QuantityPoint AUTO operator-(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs)
|
||||||
requires requires { lhs.relative() - rhs; }
|
requires requires { lhs.relative() - rhs; }
|
||||||
{
|
{
|
||||||
return quantity_point(lhs.relative() - rhs);
|
return quantity_point(lhs.relative() - rhs);
|
||||||
|
Reference in New Issue
Block a user