mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 05:04:27 +02:00
Spaceship support added (resolves #19)
This commit is contained in:
@@ -25,6 +25,9 @@
|
|||||||
#include <units/bits/concepts.h>
|
#include <units/bits/concepts.h>
|
||||||
#include <units/bits/dimension_op.h>
|
#include <units/bits/dimension_op.h>
|
||||||
#include <units/bits/unit_text.h>
|
#include <units/bits/unit_text.h>
|
||||||
|
#if __GNUC__ >= 10
|
||||||
|
#include <compare>
|
||||||
|
#endif
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
@@ -479,6 +482,31 @@ public:
|
|||||||
return ret(ret(lhs).count() % ret(rhs).count());
|
return ret(ret(lhs).count() % ret(rhs).count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __GNUC__ >= 10
|
||||||
|
|
||||||
|
template<typename D2, typename U2, typename Rep2>
|
||||||
|
[[nodiscard]] friend constexpr auto operator<=>(const quantity& lhs, const quantity<D2, U2, Rep2>& rhs)
|
||||||
|
requires equivalent_dim<D, D2> &&
|
||||||
|
detail::basic_arithmetic<Rep, Rep2> &&
|
||||||
|
std::totally_ordered_with<Rep, Rep2>
|
||||||
|
{
|
||||||
|
using cq = common_quantity<quantity, quantity<D2, U2, Rep2>>;
|
||||||
|
return cq(lhs).count() <=> cq(rhs).count();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO op== not needed (gcc bug)
|
||||||
|
template<typename D2, typename U2, typename Rep2>
|
||||||
|
[[nodiscard]] friend constexpr auto operator==(const quantity& lhs, const quantity<D2, U2, Rep2>& rhs)
|
||||||
|
requires equivalent_dim<D, D2> &&
|
||||||
|
detail::basic_arithmetic<Rep, Rep2> &&
|
||||||
|
std::equality_comparable_with<Rep, Rep2>
|
||||||
|
{
|
||||||
|
using cq = common_quantity<quantity, quantity<D2, U2, Rep2>>;
|
||||||
|
return cq(lhs).count() == cq(rhs).count();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
template<typename D2, typename U2, typename Rep2>
|
template<typename D2, typename U2, typename Rep2>
|
||||||
[[nodiscard]] friend constexpr bool operator==(const quantity& lhs, const quantity<D2, U2, Rep2>& rhs)
|
[[nodiscard]] friend constexpr bool operator==(const quantity& lhs, const quantity<D2, U2, Rep2>& rhs)
|
||||||
requires equivalent_dim<D, D2> &&
|
requires equivalent_dim<D, D2> &&
|
||||||
@@ -535,6 +563,8 @@ public:
|
|||||||
return !(lhs < rhs);
|
return !(lhs < rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class CharT, class Traits>
|
template<class CharT, class Traits>
|
||||||
friend std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const quantity& q)
|
friend std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const quantity& q)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user