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/include | |
| parent | fb2fbeca028d7a854df1c4b23bd0395d11e1f724 (diff) | |
| download | turns-main.tar.xz turns-main.zip | |
lib: make Turns.Participant comparablemain
Diffstat (limited to 'lib/include')
| -rw-r--r-- | lib/include/turns-participant.h | 14 | ||||
| -rw-r--r-- | lib/include/turnsmm/participant.hpp | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/include/turns-participant.h b/lib/include/turns-participant.h index 28588a7..695d029 100644 --- a/lib/include/turns-participant.h +++ b/lib/include/turns-participant.h @@ -8,6 +8,7 @@ #include <glib-object.h> #include <glib.h> +#include <glibconfig.h> G_BEGIN_DECLS @@ -66,6 +67,19 @@ TurnsParticipant * turns_participant_new(void); G_GNUC_WARN_UNUSED_RESULT TurnsParticipant * turns_participant_new_with(gchar const * name, gfloat priority, TurnsParticipantDisposition disposition); + +/** + * turns_participant_compare: + * @self: A #TurnsParticipant + * @other: A #TurnsParticipant + * + * Compares two participants by priority. + * + * Returns: a new `TurnsParticipant` + */ +G_GNUC_WARN_UNUSED_RESULT +gint turns_participant_compare(TurnsParticipant const * self, TurnsParticipant const * other); + /** * turns_participant_get_active: (get-property active) * @self: a participant diff --git a/lib/include/turnsmm/participant.hpp b/lib/include/turnsmm/participant.hpp index d7956ab..29ea1fa 100644 --- a/lib/include/turnsmm/participant.hpp +++ b/lib/include/turnsmm/participant.hpp @@ -17,6 +17,8 @@ #include <glibmm/refptr.h> #include <glibmm/ustring.h> +#include <compare> + namespace Turns { @@ -45,6 +47,9 @@ namespace Turns Participant(); Participant(Glib::ustring const & name, float priority, Disposition disposition); + auto operator<=>(Participant const & other) const noexcept -> std::strong_ordering; + auto operator==(Participant const & other) const noexcept -> bool; + [[nodiscard]] auto gobj() noexcept -> BaseObjectType *; [[nodiscard]] auto gobj() const -> BaseObjectType const *; [[nodiscard]] auto gobj_copy() noexcept -> BaseObjectType *; @@ -79,6 +84,11 @@ namespace Turns explicit Participant(BaseObjectType * gobj); }; + auto inline operator<=>(Glib::RefPtr<Participant> const & lhs, Glib::RefPtr<Participant> const & rhs) noexcept -> std::strong_ordering + { + return *lhs <=> *rhs; + } + } // namespace Turns namespace Glib |
