diff --git a/Telegram/SourceFiles/mtproto/core_types.h b/Telegram/SourceFiles/mtproto/core_types.h index 05aafa69a..0437644be 100644 --- a/Telegram/SourceFiles/mtproto/core_types.h +++ b/Telegram/SourceFiles/mtproto/core_types.h @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include #include +#include #include using mtpPrime = int32; @@ -243,6 +244,18 @@ inline MTPvector MTP_vector() { return tl::make_vector(); } +// ranges::to doesn't work with Qt 6 in Clang, +// because QVector is a type alias for QList there. +template +inline auto MTP_vector_from_range(Rng &&range) { + using T = std::remove_cvref_t; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0) + return MTP_vector(std::forward(range) | ranges::to()); +#else // QT_VERSION >= 6.0 + return MTP_vector(std::forward(range) | ranges::to()); +#endif // QT_VERSION < 6.0 +} + namespace tl { template diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index 6099314be..9d58ad590 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -295,11 +295,11 @@ MTPInputInvoice Form::inputInvoice() const { return MTP_inputInvoicePremiumGiftCode( MTP_inputStorePaymentPremiumGiftCode( MTP_flags(users->boostPeer ? Flag::f_boost_peer : Flag()), - MTP_vector(ranges::views::all( + MTP_vector_from_range(ranges::views::all( users->users ) | ranges::views::transform([](not_null user) { return MTPInputUser(user->inputUser); - }) | ranges::to), + })), users->boostPeer ? users->boostPeer->input : MTPInputPeer(), MTP_string(giftCode.currency), MTP_long(giftCode.amount)), @@ -321,16 +321,16 @@ MTPInputInvoice Form::inputInvoice() const { ? Flag() : Flag::f_countries_iso2)), giveaway.boostPeer->input, - MTP_vector(ranges::views::all( + MTP_vector_from_range(ranges::views::all( giveaway.additionalChannels ) | ranges::views::transform([](not_null c) { return MTPInputPeer(c->input); - }) | ranges::to()), - MTP_vector(ranges::views::all( + })), + MTP_vector_from_range(ranges::views::all( giveaway.countries ) | ranges::views::transform([](QString value) { return MTP_string(value); - }) | ranges::to()), + })), MTP_long(giftCode.randomId), MTP_int(giveaway.untilDate), MTP_string(giftCode.currency),