From 03daaf85bef39c6d6ed7fe7f5a7924913de51595 Mon Sep 17 00:00:00 2001 From: PobreGato <315121269+pobregat0@users.noreply.github.com> Date: Tue, 18 Aug 2026 03:06:31 +0300 Subject: [PATCH] compare tags by value in ordered containers --- libi2pd/Tag.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libi2pd/Tag.h b/libi2pd/Tag.h index 9af51bea..850d443c 100644 --- a/libi2pd/Tag.h +++ b/libi2pd/Tag.h @@ -14,6 +14,9 @@ #include #include #include +#if __cplusplus >= 202002L // C++20 +#include +#endif #include "Base.h" namespace i2p @@ -35,6 +38,11 @@ namespace data bool operator== (const Tag& other) const { return !memcmp (m_Buf, other.m_Buf, sz); } bool operator!= (const Tag& other) const { return !(*this == other); } bool operator< (const Tag& other) const { return memcmp (m_Buf, other.m_Buf, sz) < 0; } +#if __cplusplus >= 202002L // C++20 + // without it std::pair and std::tuple pick the built-in comparison of + // the pointer this converts to, and equal tags come out different + std::strong_ordering operator<=> (const Tag& other) const { return memcmp (m_Buf, other.m_Buf, sz) <=> 0; } +#endif uint8_t * operator()() { return m_Buf; } const uint8_t * operator()() const { return m_Buf; }