From ca2bee015b1653a0b7b486c351f3cd9a00d692d7 Mon Sep 17 00:00:00 2001 From: clyne Date: Sat, 6 Feb 2021 11:26:19 -0500 Subject: [PATCH] Fix <=> comparison --- ini_config.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ini_config.hpp b/ini_config.hpp index 9719bd2..59d779c 100644 --- a/ini_config.hpp +++ b/ini_config.hpp @@ -15,6 +15,7 @@ #endif #include // std::integral, std::floating_point +#include // std::strong_ordering namespace ini_config { @@ -292,9 +293,15 @@ public: get_next(); return copy; } - // BUG: iter < end() == false at element before end() constexpr auto operator<=>(const iterator& other) const noexcept { - return m_pos <=> other.m_pos; + if (auto poscomp = m_pos <=> other.m_pos; poscomp != 0) + return poscomp; + if (m_current.first == nullptr) + return std::strong_ordering::greater; + else if (other.m_current.first == nullptr) + return std::strong_ordering::less; + else + return m_current.first <=> other.m_current.first; } constexpr bool operator==(const iterator& other) const noexcept { return m_pos == other.m_pos && m_current.first == other.m_current.first;