fix: operators to behave like the underlying type's
This commit is contained in:
1 parent
58903e46e6
commit
00d182e133
5 files changed
+111
-47
No files matched your search
@@ -189,8 +189,9 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr quantity_kind& operator%=(const rep& rhs)
|
||||
requires requires(quantity_type q) { q %= rhs; }
|
||||
template<typename Rep2>
|
||||
constexpr quantity_kind& operator%=(const Rep2& rhs)
|
||||
requires (!Quantity<Rep2>) && requires(quantity_type q, const Rep2 r) { q %= r; }
|
||||
{
|
||||
q_ %= rhs;
|
||||
return *this;
|
||||
@@ -205,18 +206,6 @@ public:
|
||||
|
||||
// Hidden Friends
|
||||
// Below friend functions are to be found via argument-dependent lookup only
|
||||
[[nodiscard]] friend constexpr quantity_kind operator+(const quantity_kind& lhs, const quantity_kind& rhs)
|
||||
requires requires { lhs.common() + rhs.common(); }
|
||||
{
|
||||
return quantity_kind(lhs.common() + rhs.common());
|
||||
}
|
||||
|
||||
[[nodiscard]] friend constexpr quantity_kind operator-(const quantity_kind& lhs, const quantity_kind& rhs)
|
||||
requires requires { lhs.common() - rhs.common(); }
|
||||
{
|
||||
return quantity_kind(lhs.common() - rhs.common());
|
||||
}
|
||||
|
||||
template<QuantityValue Value>
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator*(const quantity_kind& qk, const Value& v)
|
||||
requires requires { { qk.common() * v } -> Quantity; }
|
||||
@@ -252,12 +241,6 @@ public:
|
||||
return detail::make_quantity_kind<quantity_kind>(qk.common() % v);
|
||||
}
|
||||
|
||||
[[nodiscard]] friend constexpr quantity_kind operator%(const quantity_kind& lhs, const quantity_kind& rhs)
|
||||
requires requires { lhs.common() % rhs.common(); }
|
||||
{
|
||||
return quantity_kind(lhs.common() % rhs.common());
|
||||
}
|
||||
|
||||
[[nodiscard]] friend constexpr auto operator<=>(const quantity_kind& lhs, const quantity_kind& rhs)
|
||||
requires std::three_way_comparable<quantity_type>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user