mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
Starship improvements after the latest gcc fixes
This commit is contained in:
@@ -81,7 +81,6 @@ public:
|
|||||||
#if __GNUC__ >= 10
|
#if __GNUC__ >= 10
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr auto operator<=>(const measurement& lhs, const measurement& rhs) = default;
|
[[nodiscard]] friend constexpr auto operator<=>(const measurement& lhs, const measurement& rhs) = default;
|
||||||
[[nodiscard]] friend constexpr bool operator==(const measurement& lhs, const measurement& rhs) = default; // TODO op== not needed (gcc bug)
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
45
src/include/units/bits/external/fixed_string.h
vendored
45
src/include/units/bits/external/fixed_string.h
vendored
@@ -31,6 +31,9 @@ template<typename CharT, std::size_t N>
|
|||||||
struct basic_fixed_string {
|
struct basic_fixed_string {
|
||||||
CharT data_[N + 1] = {};
|
CharT data_[N + 1] = {};
|
||||||
|
|
||||||
|
using iterator = CharT*;
|
||||||
|
using const_iterator = const CharT*;
|
||||||
|
|
||||||
constexpr basic_fixed_string(CharT ch) noexcept { data_[0] = ch; }
|
constexpr basic_fixed_string(CharT ch) noexcept { data_[0] = ch; }
|
||||||
|
|
||||||
constexpr basic_fixed_string(const CharT (&txt)[N + 1]) noexcept
|
constexpr basic_fixed_string(const CharT (&txt)[N + 1]) noexcept
|
||||||
@@ -43,6 +46,11 @@ struct basic_fixed_string {
|
|||||||
[[nodiscard]] constexpr const CharT& operator[](std::size_t index) const noexcept { return data_[index]; }
|
[[nodiscard]] constexpr const CharT& operator[](std::size_t index) const noexcept { return data_[index]; }
|
||||||
[[nodiscard]] constexpr CharT operator[](std::size_t index) noexcept { return data_[index]; }
|
[[nodiscard]] constexpr CharT operator[](std::size_t index) noexcept { return data_[index]; }
|
||||||
|
|
||||||
|
[[nodiscard]] constexpr iterator begin() noexcept { return std::begin(data_); }
|
||||||
|
[[nodiscard]] constexpr const_iterator begin() const noexcept { return std::begin(data_); }
|
||||||
|
[[nodiscard]] constexpr iterator end() noexcept { return std::end(data_); }
|
||||||
|
[[nodiscard]] constexpr const_iterator end() const noexcept { return std::end(data_); }
|
||||||
|
|
||||||
template<std::size_t N2>
|
template<std::size_t N2>
|
||||||
[[nodiscard]] constexpr friend basic_fixed_string<CharT, N + N2> operator+(
|
[[nodiscard]] constexpr friend basic_fixed_string<CharT, N + N2> operator+(
|
||||||
const basic_fixed_string& lhs, const basic_fixed_string<CharT, N2>& rhs) noexcept
|
const basic_fixed_string& lhs, const basic_fixed_string<CharT, N2>& rhs) noexcept
|
||||||
@@ -57,41 +65,18 @@ struct basic_fixed_string {
|
|||||||
|
|
||||||
#if __GNUC__ >= 10
|
#if __GNUC__ >= 10
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr bool operator==(const basic_fixed_string& lhs, const basic_fixed_string& rhs)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i != lhs.size(); ++i)
|
|
||||||
if (lhs[i] != rhs[i]) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr bool operator!=(const basic_fixed_string&, const basic_fixed_string&) = default;
|
|
||||||
|
|
||||||
template<typename CharT2, std::size_t N2>
|
|
||||||
[[nodiscard]] friend constexpr bool operator==(const basic_fixed_string&, const basic_fixed_string<CharT2, N2>&)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CharT2, std::size_t N2>
|
|
||||||
// TODO gcc-10 error: a template cannot be defaulted
|
|
||||||
// [[nodiscard]] friend constexpr bool operator!=(const basic_fixed_string&,
|
|
||||||
// const basic_fixed_string<CharT2, N2>&) = default;
|
|
||||||
[[nodiscard]] friend constexpr bool operator!=(const basic_fixed_string&, const basic_fixed_string<CharT2, N2>&)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename CharT2, std::size_t N2>
|
template<typename CharT2, std::size_t N2>
|
||||||
[[nodiscard]] friend constexpr auto operator<=>(const basic_fixed_string& lhs,
|
[[nodiscard]] friend constexpr auto operator<=>(const basic_fixed_string& lhs,
|
||||||
const basic_fixed_string<CharT2, N2>& rhs)
|
const basic_fixed_string<CharT2, N2>& rhs)
|
||||||
{
|
{
|
||||||
size_t min_size = std::min(lhs.size(), rhs.size());
|
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||||
for (size_t i = 0; i != min_size; ++i) {
|
|
||||||
if (auto const cmp = lhs[i] <=> rhs[i]; cmp != 0) {
|
|
||||||
return cmp;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return lhs.size() <=> rhs.size();
|
template<typename CharT2, std::size_t N2>
|
||||||
|
[[nodiscard]] friend constexpr bool operator==(const basic_fixed_string& lhs,
|
||||||
|
const basic_fixed_string<CharT2, N2>& rhs)
|
||||||
|
{
|
||||||
|
return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@@ -235,7 +235,6 @@ public:
|
|||||||
return cq(lhs).count() <=> cq(rhs).count();
|
return cq(lhs).count() <=> cq(rhs).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO op== not needed (gcc bug)
|
|
||||||
template<typename D2, typename U2, typename Rep2>
|
template<typename D2, typename U2, typename Rep2>
|
||||||
[[nodiscard]] friend constexpr auto operator==(const quantity& lhs, const quantity<D2, U2, Rep2>& rhs)
|
[[nodiscard]] friend constexpr auto operator==(const quantity& lhs, const quantity<D2, U2, Rep2>& rhs)
|
||||||
requires equivalent_dim<D, D2> &&
|
requires equivalent_dim<D, D2> &&
|
||||||
|
Reference in New Issue
Block a user