refactor: got rid of gcc-9 backlog

BREAKING CHANGE: gcc-9.3 no longer supported
This commit is contained in:
Mateusz Pusz
2020-09-08 13:09:34 +02:00
parent 7ed4f19ef3
commit 4bb51586dc
27 changed files with 131 additions and 760 deletions
+2 -38
View File
@@ -22,11 +22,8 @@
#include <units/physical/si/acceleration.h>
#include <cmath>
#include <iostream>
#if COMP_MSVC || COMP_GCC >= 10
#include <compare>
#endif
#include <iostream>
namespace {
@@ -105,41 +102,8 @@ public:
return measurement(val, val * rhs.relative_uncertainty());
}
#if COMP_MSVC || COMP_GCC >= 10
[[nodiscard]] constexpr auto operator<=>(const measurement&) const = default;
#else
[[nodiscard]] friend constexpr bool operator==(const measurement& lhs, const measurement& rhs)
{
return lhs.value() == rhs.value() && lhs.uncertainty() == rhs.uncertainty();
}
[[nodiscard]] friend constexpr bool operator!=(const measurement& lhs, const measurement& rhs)
{
return !(lhs == rhs);
}
[[nodiscard]] friend constexpr bool operator<(const measurement& lhs, const measurement& rhs)
{
return lhs.value() == rhs.value() ? lhs.uncertainty() < rhs.uncertainty() : lhs.value() < rhs.value();
}
[[nodiscard]] friend constexpr bool operator>(const measurement& lhs, const measurement& rhs) { return rhs < lhs; }
[[nodiscard]] friend constexpr bool operator<=(const measurement& lhs, const measurement& rhs)
{
return !(rhs < lhs);
}
[[nodiscard]] friend constexpr bool operator>=(const measurement& lhs, const measurement& rhs)
{
return !(lhs < rhs);
}
#endif
friend std::ostream& operator<<(std::ostream& os, const measurement& v)
{
return os << v.value() << " ± " << v.uncertainty();
@@ -166,7 +130,7 @@ void example()
const auto a = si::acceleration<si::metre_per_second_sq, measurement<double>>(measurement(9.8, 0.1));
const auto t = si::time<si::second, measurement<double>>(measurement(1.2, 0.1));
const Speed AUTO v1 = a * t;
const Speed auto v1 = a * t;
std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast<si::kilometre_per_hour>(v1) << '\n';
si::length<si::metre, measurement<double>> length(measurement(123., 1.));