From d734f1e7803a756822524e0580ec8e9c93b821c6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 25 Jul 2025 22:59:30 +0200 Subject: lib: make Turns.Participant comparable --- lib/src/turnsmm/participant.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/src/turnsmm') diff --git a/lib/src/turnsmm/participant.cpp b/lib/src/turnsmm/participant.cpp index 758f062..81b2777 100644 --- a/lib/src/turnsmm/participant.cpp +++ b/lib/src/turnsmm/participant.cpp @@ -22,6 +22,7 @@ #include #include +#include namespace Turns { @@ -84,6 +85,17 @@ namespace Turns { } + auto Participant::operator<=>(Participant const & other) const noexcept -> std::strong_ordering + { + auto result = turns_participant_compare(unwrap(this), other.gobj()); + return result == 0 ? std::strong_ordering::equivalent : (result < 0 ? std::strong_ordering::less : std::strong_ordering::greater); + } + + auto Participant::operator==(Participant const & other) const noexcept -> bool + { + return (*this <=> other) == std::strong_ordering::equivalent; + } + auto Participant::gobj() noexcept -> BaseObjectType * { return std::bit_cast(gobject_); -- cgit v1.2.3