From d1796a515ef04e99fe5b9a56315f976b0c674cb5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 29 Jun 2025 19:50:54 +0300 Subject: [PATCH] Fixed comparing of credits amount with different types. --- Telegram/SourceFiles/core/credits_amount.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/core/credits_amount.h b/Telegram/SourceFiles/core/credits_amount.h index c32d43a1d6..e4c3a2d09f 100644 --- a/Telegram/SourceFiles/core/credits_amount.h +++ b/Telegram/SourceFiles/core/credits_amount.h @@ -107,12 +107,14 @@ public: friend inline constexpr auto operator<=>( CreditsAmount a, CreditsAmount b) { - if (const auto r1 = (int(a._ton) <=> int(b._ton)); r1 != 0) { + if (const auto r1 = (a._whole <=> b._whole); r1 != 0) { return r1; - } else if (auto r2 = (a._whole <=> b._whole); r2 != 0) { + } else if (const auto r2 = (a._nano <=> b._nano); r2 != 0) { return r2; } - return (a._nano <=> b._nano); + return (a._whole || a._nano) + ? (int(a._ton) <=> int(b._ton)) + : std::strong_ordering::equal; } friend inline bool operator==(CreditsAmount, CreditsAmount)