diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-07-25 22:59:30 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-07-25 22:59:30 +0200 |
| commit | d734f1e7803a756822524e0580ec8e9c93b821c6 (patch) | |
| tree | 28daa14da0ec330adaa87f1316167cf18274cfe4 /lib/src/turnsmm/participant.cpp | |
| parent | fb2fbeca028d7a854df1c4b23bd0395d11e1f724 (diff) | |
| download | turns-main.tar.xz turns-main.zip | |
lib: make Turns.Participant comparablemain
Diffstat (limited to 'lib/src/turnsmm/participant.cpp')
| -rw-r--r-- | lib/src/turnsmm/participant.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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 <glibmm/wrap.h> #include <bit> +#include <compare> 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<BaseObjectType *>(gobject_); |
