diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 34f5c518d1..88391f2a83 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -2684,14 +2684,14 @@ void ApiWrap::requestFileReference( // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87122 const auto &origin = p.first; const auto &reference = p.second; - const auto documentId = base::get_if( + const auto documentId = std::get_if( &origin); if (documentId) { _session->data().document( documentId->id )->refreshFileReference(reference); } - const auto photoId = base::get_if(&origin); + const auto photoId = std::get_if(&origin); if (photoId) { _session->data().photo( photoId->id @@ -2826,7 +2826,7 @@ void ApiWrap::refreshFileReference( MTP_long(data.themeId), MTP_long(data.accessHash)), MTP_long(0))); - }, [&](std::nullopt_t) { + }, [&](v::null_t) { fail(); }); } diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 6b729c03e3..a45d181169 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -446,7 +446,7 @@ int BackgroundBox::Inner::getSelectionIndex( return data.index; }, [](const DeleteSelected &data) { return data.index; - }, [](std::nullopt_t) { + }, [](v::null_t) { return -1; }); } diff --git a/Telegram/SourceFiles/boxes/dictionaries_manager.cpp b/Telegram/SourceFiles/boxes/dictionaries_manager.cpp index b9d25586dc..5bf50e8096 100644 --- a/Telegram/SourceFiles/boxes/dictionaries_manager.cpp +++ b/Telegram/SourceFiles/boxes/dictionaries_manager.cpp @@ -225,7 +225,7 @@ auto AddButtonWithLoader( buttonState->value( ) | rpl::start_with_next([=](const DictState &state) { - const auto isToggledSet = state.is(); + const auto isToggledSet = v::is(state); const auto toggled = isToggledSet ? 1. : 0.; const auto over = !button->isDisabled() && (button->isDown() || button->isOver()); @@ -252,7 +252,7 @@ auto AddButtonWithLoader( dictionaryRemoved->events(), buttonState->value( ) | rpl::filter([](const DictState &state) { - return state.is(); + return v::is(state); }) | rpl::to_empty ) | rpl::map_to(false) ) @@ -276,13 +276,14 @@ auto AddButtonWithLoader( }); }) | rpl::flatten_latest( ) | rpl::filter([=](const DictState &state) { - return !buttonState->current().is() || !state.is(); + return !v::is(buttonState->current()) + || !v::is(state); }); button->toggledValue( ) | rpl::start_with_next([=](bool toggled) { const auto &state = buttonState->current(); - if (toggled && (state.is() || state.is())) { + if (toggled && (v::is(state) || v::is(state))) { const auto weak = Ui::MakeWeak(button); setLocalLoader(base::make_unique_q( QCoreApplication::instance(), @@ -292,7 +293,7 @@ auto AddButtonWithLoader( Spellchecker::DictPathByLangId(id), Spellchecker::GetDownloadSize(id), crl::guard(weak, destroyLocalLoader))); - } else if (!toggled && state.is()) { + } else if (!toggled && v::is(state)) { if (const auto g = rawGlobalLoaderPtr()) { g->destroy(); return; diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 32f00f56bb..5f30d3eb50 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -431,7 +431,7 @@ void EditCaptionBox::setupStreamedPreview(std::shared_ptr shared) { } void EditCaptionBox::handleStreamingUpdate(Update &&update) { - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { streamingReady(std::move(update)); }, [&](const PreloadedVideo &update) { }, [&](const UpdateVideo &update) { diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 87fe7d432e..0453094e60 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -395,7 +395,7 @@ void Rows::mouseReleaseEvent(QMouseEvent *e) { activateByIndex(data.index); }, [&](MenuSelection data) { showMenu(data.index); - }, [](std::nullopt_t) {}); + }, [](v::null_t) {}); } } @@ -601,7 +601,7 @@ int Rows::indexFromSelection(Selection selected) const { return data.index; }, [&](MenuSelection data) { return data.index; - }, [](std::nullopt_t) { + }, [](v::null_t) { return -1; }); } @@ -648,7 +648,7 @@ rpl::producer Rows::isEmpty() const { } void Rows::repaint(Selection selected) { - selected.match([](std::nullopt_t) { + selected.match([](v::null_t) { }, [&](const auto &data) { repaint(data.index); }); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index b53efb2afc..c6e37779ec 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -263,8 +263,8 @@ void Row::paintRadio(Painter &p) { const auto loading = _loading ? _loading->computeState() : Ui::RadialState{ 0., 0, FullArcLength }; - const auto isToggledSet = _state.current().is(); - const auto isActiveSet = isToggledSet || _state.current().is(); + const auto isToggledSet = v::is(_state.current()); + const auto isActiveSet = isToggledSet || v::is(_state.current()); const auto toggled = _toggled.value(isToggledSet ? 1. : 0.); const auto active = _active.value(isActiveSet ? 1. : 0.); const auto _st = &st::defaultRadio; @@ -345,7 +345,7 @@ void Row::onStateChanged(State was, StateChangeSource source) { } void Row::updateStatusColorOverride() { - const auto isToggledSet = _state.current().is(); + const auto isToggledSet = v::is(_state.current()); const auto toggled = _toggled.value(isToggledSet ? 1. : 0.); const auto over = showOver(); if (toggled == 0. && !over) { @@ -373,7 +373,8 @@ void Row::setupContent(const Set &set) { }); }) | rpl::flatten_latest( ) | rpl::filter([=](const SetState &state) { - return !_state.current().is() || !state.is(); + return !v::is(_state.current()) + || !v::is(state); }); setupLabels(set); @@ -390,9 +391,10 @@ void Row::setupHandler() { clicks( ) | rpl::filter([=] { const auto &state = _state.current(); - return !_switching && (state.is() || state.is()); + return !_switching && (v::is(state) + || v::is(state)); }) | rpl::start_with_next([=] { - if (_state.current().is()) { + if (v::is(_state.current())) { load(); return; } @@ -409,7 +411,7 @@ void Row::setupHandler() { _state.value( ) | rpl::map([=](const SetState &state) { - return state.is() || state.is(); + return v::is(state) || v::is(state); }) | rpl::start_with_next([=](bool active) { setDisabled(!active); setPointerCursor(active); @@ -463,7 +465,7 @@ void Row::setupPreview(const Set &set) { void Row::updateLoadingToFinished() { _loading->update( - _state.current().is() ? 0. : 1., + v::is(_state.current()) ? 0. : 1., true, crl::now()); } @@ -471,7 +473,7 @@ void Row::updateLoadingToFinished() { void Row::radialAnimationCallback(crl::time now) { const auto updated = [&] { const auto state = _state.current(); - if (const auto loading = base::get_if(&state)) { + if (const auto loading = std::get_if(&state)) { return _loading->update(CountProgress(loading), false, now); } else { updateLoadingToFinished(); @@ -493,7 +495,7 @@ void Row::setupAnimation() { _state.value( ) | rpl::map( - _1 == Active() + _1 == SetState{ Active() } ) | rpl::distinct_until_changed( ) | rpl::start_with_next([=](bool toggled) { _toggled.start( @@ -505,7 +507,7 @@ void Row::setupAnimation() { _state.value( ) | rpl::map([](const SetState &state) { - return state.is() || state.is(); + return v::is(state) || v::is(state); }) | rpl::distinct_until_changed( ) | rpl::start_with_next([=](bool active) { _active.start( @@ -517,7 +519,7 @@ void Row::setupAnimation() { _state.value( ) | rpl::map([](const SetState &state) { - return base::get_if(&state); + return std::get_if(&state); }) | rpl::distinct_until_changed( ) | rpl::start_with_next([=](const Loading *loading) { if (loading && !_loading) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 1d5dcc2f63..31ec40000e 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -143,7 +143,7 @@ private: Search, Settings, }; - using OverState = base::variant; + using OverState = std::variant; template void enumerateVisibleIcons(Callback callback); @@ -548,7 +548,7 @@ void StickersListWidget::Footer::mouseMoveEvent(QMouseEvent *e) { if (!_iconsDragging && !_icons.empty() - && base::get_if(&_iconDown) != nullptr) { + && v::is(_iconDown)) { if ((_iconsMousePos - _iconsMouseDown).manhattanLength() >= QApplication::startDragDistance()) { _iconsDragging = true; } @@ -579,7 +579,7 @@ void StickersListWidget::Footer::mouseReleaseEvent(QMouseEvent *e) { updateSelected(); if (wasDown == _iconOver) { - if (const auto index = base::get_if(&_iconOver)) { + if (const auto index = std::get_if(&_iconOver)) { _iconSelX = anim::value( *index * st::stickerIconWidth, *index * st::stickerIconWidth); @@ -604,7 +604,7 @@ bool StickersListWidget::Footer::eventHook(QEvent *e) { if (e->type() == QEvent::TouchBegin) { } else if (e->type() == QEvent::Wheel) { if (!_icons.empty() - && (base::get_if(&_iconOver) != nullptr) + && v::is(_iconOver) && (_iconDown == SpecialOver::None)) { scrollByWheelEvent(static_cast(e)); } @@ -635,7 +635,7 @@ void StickersListWidget::Footer::scrollByWheelEvent( } void StickersListWidget::Footer::updateSelected() { - if (_iconDown >= 0) { + if (_iconDown != SpecialOver::None) { return; } @@ -2109,7 +2109,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) { _previewTimer.cancel(); auto pressed = _pressed; - setPressed(std::nullopt); + setPressed(v::null); if (pressed != _selected) { update(); } @@ -2271,8 +2271,8 @@ void StickersListWidget::enterFromChildEvent(QEvent *e, QWidget *child) { } void StickersListWidget::clearSelection() { - setPressed(std::nullopt); - setSelected(std::nullopt); + setPressed(v::null); + setSelected(v::null); update(); } @@ -2754,7 +2754,7 @@ void StickersListWidget::updateSelected() { return; } - auto newSelected = OverState { std::nullopt }; + auto newSelected = OverState { v::null }; auto p = mapFromGlobal(_lastMousePosition); if (!rect().contains(p) || p.y() < getVisibleTop() || p.y() >= getVisibleBottom() diff --git a/Telegram/SourceFiles/core/core_cloud_password.cpp b/Telegram/SourceFiles/core/core_cloud_password.cpp index 22b14a7175..a5e979200b 100644 --- a/Telegram/SourceFiles/core/core_cloud_password.cpp +++ b/Telegram/SourceFiles/core/core_cloud_password.cpp @@ -157,7 +157,7 @@ CloudPasswordResult ComputeCheck( } bytes::vector ComputeHash( - std::nullopt_t, + v::null_t, bytes::const_span password) { Unexpected("Bad secure secret algorithm."); } @@ -200,7 +200,7 @@ CloudPasswordCheckRequest ParseCloudPasswordCheckRequest( CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) { if (!parsed.is()) { - return std::nullopt; + return v::null; } auto &value = parsed.get_unchecked(); const auto already = value.salt1.size(); @@ -216,7 +216,7 @@ MTPPasswordKdfAlgo PrepareCloudPasswordAlgo(const CloudPasswordAlgo &data) { MTP_bytes(data.salt2), MTP_int(data.g), MTP_bytes(data.p)); - }, [](std::nullopt_t) { + }, [](v::null_t) { return MTP_passwordKdfAlgoUnknown(); }); } @@ -230,7 +230,7 @@ bytes::vector ComputeCloudPasswordHash( bytes::const_span password) { return algo.match([&](const CloudPasswordAlgoModPow &data) { return ComputeHash(data, password); - }, [](std::nullopt_t) -> bytes::vector { + }, [](v::null_t) -> bytes::vector { Unexpected("Bad cloud password algorithm."); }); } @@ -240,7 +240,7 @@ CloudPasswordDigest ComputeCloudPasswordDigest( bytes::const_span password) { return algo.match([&](const CloudPasswordAlgoModPow &data) { return ComputeDigest(data, password); - }, [](std::nullopt_t) -> CloudPasswordDigest { + }, [](v::null_t) -> CloudPasswordDigest { Unexpected("Bad cloud password algorithm."); }); } @@ -250,7 +250,7 @@ CloudPasswordResult ComputeCloudPasswordCheck( bytes::const_span hash) { return request.algo.match([&](const CloudPasswordAlgoModPow &data) { return ComputeCheck(request, data, hash); - }, [](std::nullopt_t) -> CloudPasswordResult { + }, [](v::null_t) -> CloudPasswordResult { Unexpected("Bad cloud password algorithm."); }); } @@ -271,7 +271,7 @@ SecureSecretAlgo ParseSecureSecretAlgo( SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) { if (!parsed.is()) { - return std::nullopt; + return v::null; } auto &value = parsed.get_unchecked(); const auto already = value.salt.size(); @@ -287,7 +287,7 @@ MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo( MTP_bytes(data.salt)); }, [](const SecureSecretAlgoSHA512 &data) { return MTP_securePasswordKdfAlgoSHA512(MTP_bytes(data.salt)); - }, [](std::nullopt_t) { + }, [](v::null_t) { return MTP_securePasswordKdfAlgoUnknown(); }); } diff --git a/Telegram/SourceFiles/core/crash_reports.h b/Telegram/SourceFiles/core/crash_reports.h index 2af269588c..b609416428 100644 --- a/Telegram/SourceFiles/core/crash_reports.h +++ b/Telegram/SourceFiles/core/crash_reports.h @@ -35,7 +35,7 @@ enum Status { Started }; // Open status or crash report dump. -using StartResult = base::variant; +using StartResult = std::variant; StartResult Start(); Status Restart(); // can be only CantOpen or Started void Finish(); diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp index d39a105322..f2989b99ff 100644 --- a/Telegram/SourceFiles/core/sandbox.cpp +++ b/Telegram/SourceFiles/core/sandbox.cpp @@ -315,7 +315,7 @@ void Sandbox::singleInstanceChecked() { return; } const auto result = CrashReports::Start(); - result.match([&](CrashReports::Status status) { + v::match(result, [&](CrashReports::Status status) { if (status == CrashReports::CantOpen) { new NotStartedWindow(); } else { diff --git a/Telegram/SourceFiles/data/data_cloud_file.cpp b/Telegram/SourceFiles/data/data_cloud_file.cpp index 49b0fa8fa2..63aba99fb4 100644 --- a/Telegram/SourceFiles/data/data_cloud_file.cpp +++ b/Telegram/SourceFiles/data/data_cloud_file.cpp @@ -54,7 +54,7 @@ void CloudImage::set( _file.flags = CloudFile::Flag(); _view = std::weak_ptr(); } else if (was != now - && (!was.is() || now.is())) { + && (!v::is(was) || v::is(now))) { _file.location = ImageLocation(); _view = std::weak_ptr(); } @@ -176,8 +176,8 @@ void UpdateCloudFile( } auto cacheBytes = !data.bytes.isEmpty() ? data.bytes - : file.location.file().data.is() - ? file.location.file().data.get_unchecked().bytes + : v::is(file.location.file().data) + ? std::get(file.location.file().data).bytes : QByteArray(); if (!cacheBytes.isEmpty()) { if (const auto cacheKey = data.location.file().cacheKey()) { diff --git a/Telegram/SourceFiles/data/data_file_origin.h b/Telegram/SourceFiles/data/data_file_origin.h index 60936abe79..2bafc3bd38 100644 --- a/Telegram/SourceFiles/data/data_file_origin.h +++ b/Telegram/SourceFiles/data/data_file_origin.h @@ -148,7 +148,7 @@ inline bool operator<(PhotoFileLocationId a, PhotoFileLocationId b) { return a.id < b.id; } -using FileLocationId = base::variant< +using FileLocationId = std::variant< DocumentFileLocationId, PhotoFileLocationId>; diff --git a/Telegram/SourceFiles/data/data_photo.cpp b/Telegram/SourceFiles/data/data_photo.cpp index 6a80d0f05d..cee9f857b4 100644 --- a/Telegram/SourceFiles/data/data_photo.cpp +++ b/Telegram/SourceFiles/data/data_photo.cpp @@ -445,10 +445,10 @@ auto PhotoData::createStreamingLoader( return Media::Streaming::MakeBytesLoader(media->videoContent()); } } - return videoLocation().file().data.is() + return v::is(videoLocation().file().data) ? std::make_unique( &session().downloader(), - videoLocation().file().data.get_unchecked(), + std::get(videoLocation().file().data), videoByteSize(), origin) : nullptr; diff --git a/Telegram/SourceFiles/data/data_shared_media.cpp b/Telegram/SourceFiles/data/data_shared_media.cpp index 50ec88184a..849fac0e33 100644 --- a/Telegram/SourceFiles/data/data_shared_media.cpp +++ b/Telegram/SourceFiles/data/data_shared_media.cpp @@ -231,11 +231,11 @@ std::optional SharedMediaWithLastSlice::skippedAfter() const { } std::optional SharedMediaWithLastSlice::indexOfImpl(Value value) const { - return base::get_if(&value) - ? _slice.indexOf(*base::get_if(&value)) + return std::get_if(&value) + ? _slice.indexOf(*std::get_if(&value)) : (isolatedInSlice() || !_lastPhotoId - || (*base::get_if>(&value))->id != *_lastPhotoId) + || (*std::get_if>(&value))->id != *_lastPhotoId) ? std::nullopt : Add(_slice.size() - 1, lastPhotoSkip()); } @@ -267,14 +267,14 @@ std::optional SharedMediaWithLastSlice::indexOf(Value value) const { info.push_back((_ending && _ending->skippedAfter()) ? QString::number(*_ending->skippedAfter()) : QString("-")); - if (const auto msgId = base::get_if(&value)) { + if (const auto msgId = std::get_if(&value)) { info.push_back("value:" + QString::number(msgId->channel)); info.push_back(QString::number(msgId->msg)); - const auto index = _slice.indexOf(*base::get_if(&value)); + const auto index = _slice.indexOf(*std::get_if(&value)); info.push_back("index:" + (index ? QString::number(*index) : QString("-"))); - } else if (const auto photo = base::get_if>(&value)) { + } else if (const auto photo = std::get_if>(&value)) { info.push_back("value:" + QString::number((*photo)->id)); } else { info.push_back("value:bad"); @@ -373,7 +373,7 @@ rpl::producer SharedMediaWithLastViewer( int limitBefore, int limitAfter) { return [=](auto consumer) { - if (base::get_if>(&key.universalId)) { + if (std::get_if>(&key.universalId)) { return SharedMediaMergedViewer( session, SharedMediaMergedKey( diff --git a/Telegram/SourceFiles/data/data_shared_media.h b/Telegram/SourceFiles/data/data_shared_media.h index 49cd87e382..f98c31679e 100644 --- a/Telegram/SourceFiles/data/data_shared_media.h +++ b/Telegram/SourceFiles/data/data_shared_media.h @@ -60,9 +60,9 @@ class SharedMediaWithLastSlice { public: using Type = Storage::SharedMediaType; - using Value = base::variant>; + using Value = std::variant>; using MessageId = SparseIdsMergedSlice::UniversalMsgId; - using UniversalMsgId = base::variant< + using UniversalMsgId = std::variant< MessageId, not_null>; @@ -76,8 +76,7 @@ public: , migratedPeerId(migratedPeerId) , type(type) , universalId(universalId) { - Expects(base::get_if(&universalId) != nullptr - || type == Type::ChatPhoto); + Expects(v::is(universalId) || type == Type::ChatPhoto); } bool operator==(const Key &other) const { @@ -120,8 +119,8 @@ public: return { key.peerId, key.migratedPeerId, - base::get_if(&key.universalId) - ? (*base::get_if(&key.universalId)) + v::is(key.universalId) + ? std::get(key.universalId) : ServerMaxMsgId - 1 }; } @@ -135,7 +134,7 @@ public: private: static std::optional EndingSlice(const Key &key) { - return base::get_if(&key.universalId) + return v::is(key.universalId) ? base::make_optional(SparseIdsMergedSlice(EndingKey(key))) : std::nullopt; } @@ -161,12 +160,12 @@ private: msgId); } static Value ComputeId(const Key &key) { - if (auto messageId = base::get_if(&key.universalId)) { + if (const auto messageId = std::get_if(&key.universalId)) { return (*messageId >= 0) ? ComputeId(key.peerId, *messageId) : ComputeId(key.migratedPeerId, ServerMaxMsgId + *messageId); } - return *base::get_if>(&key.universalId); + return std::get>(key.universalId); } bool isolatedInSlice() const { diff --git a/Telegram/SourceFiles/data/data_web_page.h b/Telegram/SourceFiles/data/data_web_page.h index 6f05b906f7..6ec72ad484 100644 --- a/Telegram/SourceFiles/data/data_web_page.h +++ b/Telegram/SourceFiles/data/data_web_page.h @@ -29,7 +29,7 @@ enum class WebPageType { WebPageType ParseWebPageType(const MTPDwebPage &type); struct WebPageCollage { - using Item = base::variant; + using Item = std::variant; WebPageCollage() = default; explicit WebPageCollage( diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 135b2a84fe..c0eeea8d74 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -786,10 +786,10 @@ Utf8String User::name() const { } const User *Peer::user() const { - return base::get_if(&data); + return std::get_if(&data); } const Chat *Peer::chat() const { - return base::get_if(&data); + return std::get_if(&data); } PeerId Peer::id() const { diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index 847e01a527..ac768d6dea 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -240,7 +240,7 @@ struct Peer { const User *user() const; const Chat *chat() const; - base::variant data; + std::variant data; }; diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index 103ca6f983..59aea9d0de 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -1090,7 +1090,7 @@ auto HtmlWriter::Wrap::pushMessage( return serviceFrom + " joined Telegram"; }, [&](const ActionPhoneNumberRequest &data) { return serviceFrom + " requested your phone number"; - }, [](std::nullopt_t) { return QByteArray(); }); + }, [](v::null_t) { return QByteArray(); }); if (!serviceText.isEmpty()) { const auto &content = message.action.content; @@ -1753,7 +1753,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData( }, [](const Poll &data) { }, [](const UnsupportedMedia &data) { Unexpected("Unsupported message."); - }, [](std::nullopt_t) {}); + }, [](v::null_t) {}); return result; } diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index b106b9806e..dd6b19d1d6 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -471,7 +471,7 @@ QByteArray SerializeMessage( }, [&](const ActionPhoneNumberRequest &data) { pushActor(); pushAction("requested_phone_number"); - }, [](std::nullopt_t) {}); + }, [](v::null_t) {}); if (!message.action.content) { pushFrom(); @@ -612,7 +612,7 @@ QByteArray SerializeMessage( })); }, [](const UnsupportedMedia &data) { Unexpected("Unsupported message."); - }, [](std::nullopt_t) {}); + }, [](v::null_t) {}); pushBare("text", SerializeText(context, message.text)); diff --git a/Telegram/SourceFiles/export/output/export_output_text.cpp b/Telegram/SourceFiles/export/output/export_output_text.cpp index be0ebd5073..8cab557e92 100644 --- a/Telegram/SourceFiles/export/output/export_output_text.cpp +++ b/Telegram/SourceFiles/export/output/export_output_text.cpp @@ -338,7 +338,7 @@ QByteArray SerializeMessage( }, [&](const ActionPhoneNumberRequest &data) { pushActor(); pushAction("Request Phone Number"); - }, [](std::nullopt_t) {}); + }, [](v::null_t) {}); if (!message.action.content) { pushFrom(); @@ -456,7 +456,7 @@ QByteArray SerializeMessage( } }, [](const UnsupportedMedia &data) { Unexpected("Unsupported message."); - }, [](std::nullopt_t) {}); + }, [](v::null_t) {}); auto value = JoinList(QByteArray(), ranges::view::all( message.text diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index f590538bb0..d4117db3e9 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -1444,7 +1444,7 @@ void Gif::setStreamed(std::unique_ptr value) { void Gif::handleStreamingUpdate(::Media::Streaming::Update &&update) { using namespace ::Media::Streaming; - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { streamingReady(std::move(update)); }, [&](const PreloadedVideo &update) { }, [&](const UpdateVideo &update) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index 9870c1cfae..b06f27bc3f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -704,7 +704,7 @@ void Photo::setStreamed(std::unique_ptr value) { void Photo::handleStreamingUpdate(::Media::Streaming::Update &&update) { using namespace ::Media::Streaming; - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { streamingReady(std::move(update)); }, [&](const PreloadedVideo &update) { }, [&](const UpdateVideo &update) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp index 7101a1f2bd..92884b2e64 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp @@ -313,7 +313,7 @@ void Sticker::lottieCreated() { _lottie->updates( ) | rpl::start_with_next([=](Lottie::Update update) { - update.data.match([&](const Lottie::Information &information) { + v::match(update.data, [&](const Lottie::Information &information) { _parent->history()->owner().requestViewResize(_parent); }, [&](const Lottie::DisplayFrameRequest &request) { _parent->history()->owner().requestViewRepaint(_parent); diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index fda9f45957..91eb99ec21 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -53,11 +53,11 @@ std::vector> PrepareCollageMedia( auto result = std::vector>(); result.reserve(data.items.size()); for (const auto item : data.items) { - if (const auto document = base::get_if(&item)) { + if (const auto document = std::get_if(&item)) { result.push_back(std::make_unique( parent, *document)); - } else if (const auto photo = base::get_if(&item)) { + } else if (const auto photo = std::get_if(&item)) { result.push_back(std::make_unique( parent, *photo)); diff --git a/Telegram/SourceFiles/info/info_controller.cpp b/Telegram/SourceFiles/info/info_controller.cpp index 1de01a4f76..23cbebcca7 100644 --- a/Telegram/SourceFiles/info/info_controller.cpp +++ b/Telegram/SourceFiles/info/info_controller.cpp @@ -40,7 +40,7 @@ Key::Key(not_null poll, FullMsgId contextId) } PeerData *Key::peer() const { - if (const auto peer = base::get_if>(&_value)) { + if (const auto peer = std::get_if>(&_value)) { return *peer; } return nullptr; @@ -54,21 +54,21 @@ PeerData *Key::peer() const { //} UserData *Key::settingsSelf() const { - if (const auto tag = base::get_if(&_value)) { + if (const auto tag = std::get_if(&_value)) { return tag->self; } return nullptr; } PollData *Key::poll() const { - if (const auto data = base::get_if(&_value)) { + if (const auto data = std::get_if(&_value)) { return data->poll; } return nullptr; } FullMsgId Key::pollContextId() const { - if (const auto data = base::get_if(&_value)) { + if (const auto data = std::get_if(&_value)) { return data->contextId; } return FullMsgId(); diff --git a/Telegram/SourceFiles/info/info_controller.h b/Telegram/SourceFiles/info/info_controller.h index c3f097d935..741fa59fb7 100644 --- a/Telegram/SourceFiles/info/info_controller.h +++ b/Telegram/SourceFiles/info/info_controller.h @@ -46,7 +46,7 @@ private: not_null poll; FullMsgId contextId; }; - base::variant< + std::variant< not_null, //not_null, // #feed Settings::Tag, diff --git a/Telegram/SourceFiles/media/player/media_player_instance.cpp b/Telegram/SourceFiles/media/player/media_player_instance.cpp index 2150ba0c10..c96d8940f8 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.cpp +++ b/Telegram/SourceFiles/media/player/media_player_instance.cpp @@ -758,7 +758,7 @@ void Instance::handleStreamingUpdate( Streaming::Update &&update) { using namespace Streaming; - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { if (!update.video.size.isEmpty()) { data->streamed->progress.setValueChangedCallback([=]( float64, diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_common.h b/Telegram/SourceFiles/media/streaming/media_streaming_common.h index 392b4edf99..fd564e02be 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_common.h +++ b/Telegram/SourceFiles/media/streaming/media_streaming_common.h @@ -96,7 +96,7 @@ struct Finished { }; struct Update { - base::variant< + std::variant< Information, PreloadedVideo, UpdateVideo, diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_document.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_document.cpp index 398c879393..e6cf39e2aa 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_document.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_document.cpp @@ -138,7 +138,7 @@ Ui::RadialState Document::waitingState() const { } void Document::handleUpdate(Update &&update) { - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { ready(std::move(update)); }, [&](const PreloadedVideo &update) { _info.video.state.receivedTill = update.till; diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp index 2c693225f3..1549cefb05 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp @@ -228,7 +228,7 @@ void File::Context::seekToPosition( return logFatal(qstr("av_seek_frame"), error); } -base::variant File::Context::readPacket() { +std::variant File::Context::readPacket() { auto error = FFmpeg::AvErrorWrap(); auto result = FFmpeg::Packet(); @@ -312,7 +312,7 @@ void File::Context::readNextPacket() { auto result = readPacket(); if (unroll()) { return; - } else if (const auto packet = base::get_if(&result)) { + } else if (const auto packet = std::get_if(&result)) { const auto index = packet->fields().stream_index; const auto i = _queuedPackets.find(index); if (i == end(_queuedPackets)) { @@ -325,8 +325,8 @@ void File::Context::readNextPacket() { Assert(i->second.size() < kMaxQueuedPackets); } else { // Still trying to read by drain. - Assert(result.is()); - Assert(result.get().code() == AVERROR_EOF); + Assert(v::is(result)); + Assert(std::get(result).code() == AVERROR_EOF); processQueuedPackets(SleepPolicy::Allowed); if (!finished()) { handleEndOfFile(); diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_file.h b/Telegram/SourceFiles/media/streaming/media_streaming_file.h index 3b9e7091d2..80d2a030bf 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_file.h +++ b/Telegram/SourceFiles/media/streaming/media_streaming_file.h @@ -82,7 +82,7 @@ private: // TODO base::expected. [[nodiscard]] auto readPacket() - -> base::variant; + -> std::variant; void processQueuedPackets(SleepPolicy policy); void handleEndOfFile(); diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp index 2ed5bea922..d7d0b38a18 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp @@ -31,7 +31,9 @@ LoaderMtproto::LoaderMtproto( } Storage::Cache::Key LoaderMtproto::baseCacheKey() const { - return location().data.get().bigFileBaseCacheKey(); + return std::get( + location().data + ).bigFileBaseCacheKey(); } int LoaderMtproto::size() const { diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp index 743e6e221d..c5cc65afe5 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp @@ -239,7 +239,7 @@ void VideoTrackObject::readFrames() { if (delay != kTimeUnknown) { queueReadFrames(delay); } - }, [](std::nullopt_t) { + }, [](v::null_t) { }); if (result.has_value()) { break; @@ -258,12 +258,12 @@ auto VideoTrackObject::readEnoughFrames(crl::time trackTime) return result; } else if (!dropStaleFrames || !VideoTrack::IsStale(frame, trackTime)) { - return std::nullopt; + return v::null; } } }, [&](Shared::PrepareNextCheck delay) -> ReadEnoughState { return delay; - }, [&](std::nullopt_t) -> ReadEnoughState { + }, [&](v::null_t) -> ReadEnoughState { return FrameResult::Done; }); } diff --git a/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp b/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp index cdc93bac04..82fc4968af 100644 --- a/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp +++ b/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp @@ -38,7 +38,7 @@ using Context = GroupThumbs::Context; using Key = GroupThumbs::Key; Data::FileOrigin ComputeFileOrigin(const Key &key, const Context &context) { - return key.match([&](PhotoId photoId) { + return v::match(key, [&](PhotoId photoId) { return context.match([&](PeerId peerId) { return peerIsUser(peerId) ? Data::FileOriginUserPhoto(peerToUser(peerId), photoId) @@ -64,12 +64,12 @@ Context ComputeContext( Expects(index >= 0 && index < slice.size()); const auto value = slice[index]; - if (const auto photo = base::get_if>(&value)) { + if (const auto photo = std::get_if>(&value)) { if (const auto peer = (*photo)->peer) { return peer->id; } - return std::nullopt; - } else if (const auto msgId = base::get_if(&value)) { + return v::null; + } else if (const auto msgId = std::get_if(&value)) { if (const auto item = session->data().message(*msgId)) { if (!item->toHistoryMessage()) { return item->history()->peer->id; @@ -77,7 +77,7 @@ Context ComputeContext( return groupId; } } - return std::nullopt; + return v::null; } Unexpected("Variant in ComputeContext(SharedMediaWithLastSlice::Value)"); } @@ -100,9 +100,9 @@ Key ComputeKey(const SharedMediaWithLastSlice &slice, int index) { Expects(index >= 0 && index < slice.size()); const auto value = slice[index]; - if (const auto photo = base::get_if>(&value)) { + if (const auto photo = std::get_if>(&value)) { return (*photo)->id; - } else if (const auto msgId = base::get_if(&value)) { + } else if (const auto msgId = std::get_if(&value)) { return *msgId; } Unexpected("Variant in ComputeKey(SharedMediaWithLastSlice::Value)"); @@ -564,10 +564,10 @@ void GroupThumbs::animatePreviouslyAlive( auto GroupThumbs::createThumb(Key key) -> std::unique_ptr { - if (const auto photoId = base::get_if(&key)) { + if (const auto photoId = std::get_if(&key)) { const auto photo = _session->data().photo(*photoId); return createThumb(key, photo); - } else if (const auto msgId = base::get_if(&key)) { + } else if (const auto msgId = std::get_if(&key)) { if (const auto item = _session->data().message(*msgId)) { if (const auto media = item->media()) { if (const auto photo = media->photo()) { @@ -578,7 +578,7 @@ auto GroupThumbs::createThumb(Key key) } } return createThumb(key, nullptr); - } else if (const auto collageKey = base::get_if(&key)) { + } else if (const auto collageKey = std::get_if(&key)) { if (const auto itemId = base::get_if(&_context)) { if (const auto item = _session->data().message(*itemId)) { if (const auto media = item->media()) { @@ -605,9 +605,9 @@ auto GroupThumbs::createThumb( return createThumb(key, nullptr); } const auto &item = collage.items[index]; - if (const auto photo = base::get_if(&item)) { + if (const auto photo = std::get_if(&item)) { return createThumb(key, (*photo)); - } else if (const auto document = base::get_if(&item)) { + } else if (const auto document = std::get_if(&item)) { return createThumb(key, (*document)); } return createThumb(key, nullptr); diff --git a/Telegram/SourceFiles/media/view/media_view_group_thumbs.h b/Telegram/SourceFiles/media/view/media_view_group_thumbs.h index be61031720..9a91b2b8ec 100644 --- a/Telegram/SourceFiles/media/view/media_view_group_thumbs.h +++ b/Telegram/SourceFiles/media/view/media_view_group_thumbs.h @@ -37,7 +37,7 @@ public: int size() const; }; - using Key = base::variant; + using Key = std::variant; static void Refresh( not_null session, diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 1bf7d697d9..18dd4b7596 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -1116,7 +1116,7 @@ void OverlayWidget::clearSession() { clearStreaming(); delete _menu; _menu = nullptr; - setContext(std::nullopt); + setContext(v::null); _from = nullptr; _fromName = QString(); assignMediaPointer(nullptr); @@ -1589,7 +1589,7 @@ auto OverlayWidget::sharedMediaKey() const -> std::optional { _history->peer->id, _migrated ? _migrated->peer->id : 0, SharedMediaType::ChatPhoto, - _peer->userpicPhotoId() + _photo }; } if (!IsServerMsgId(_msgid.msg)) { @@ -1947,12 +1947,12 @@ void OverlayWidget::initGroupThumbs() { _groupThumbs->activateRequests( ) | rpl::start_with_next([this](View::GroupThumbs::Key key) { using CollageKey = View::GroupThumbs::CollageKey; - if (const auto photoId = base::get_if(&key)) { + if (const auto photoId = std::get_if(&key)) { const auto photo = _session->data().photo(*photoId); moveToEntity({ photo, nullptr }); - } else if (const auto itemId = base::get_if(&key)) { + } else if (const auto itemId = std::get_if(&key)) { moveToEntity(entityForItemId(*itemId)); - } else if (const auto collageKey = base::get_if(&key)) { + } else if (const auto collageKey = std::get_if(&key)) { if (_collageData) { moveToEntity(entityForCollage(collageKey->index)); } @@ -1990,7 +1990,7 @@ void OverlayWidget::showPhoto( if (context) { setContext(context); } else { - setContext(std::nullopt); + setContext(v::null); } clearControlsState(); @@ -2039,7 +2039,7 @@ void OverlayWidget::showDocument( if (context) { setContext(context); } else { - setContext(std::nullopt); + setContext(v::null); } clearControlsState(); @@ -2490,7 +2490,7 @@ QImage OverlayWidget::transformStaticContent(QPixmap content) const { void OverlayWidget::handleStreamingUpdate(Streaming::Update &&update) { using namespace Streaming; - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { streamingReady(std::move(update)); }, [&](const PreloadedVideo &update) { updatePlaybackState(); @@ -3535,29 +3535,29 @@ OverlayWidget::Entity OverlayWidget::entityForUserPhotos(int index) const { Expects(_session != nullptr); if (index < 0 || index >= _userPhotosData->size()) { - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } const auto id = (*_userPhotosData)[index]; if (const auto photo = _session->data().photo(id)) { return { photo, nullptr }; } - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } OverlayWidget::Entity OverlayWidget::entityForSharedMedia(int index) const { Expects(_sharedMediaData.has_value()); if (index < 0 || index >= _sharedMediaData->size()) { - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } auto value = (*_sharedMediaData)[index]; - if (const auto photo = base::get_if>(&value)) { + if (const auto photo = std::get_if>(&value)) { // Last peer photo. return { *photo, nullptr }; - } else if (const auto itemId = base::get_if(&value)) { + } else if (const auto itemId = std::get_if(&value)) { return entityForItemId(*itemId); } - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } OverlayWidget::Entity OverlayWidget::entityForCollage(int index) const { @@ -3567,14 +3567,14 @@ OverlayWidget::Entity OverlayWidget::entityForCollage(int index) const { const auto item = _session->data().message(_msgid); const auto &items = _collageData->items; if (!item || index < 0 || index >= items.size()) { - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } - if (const auto document = base::get_if(&items[index])) { + if (const auto document = std::get_if(&items[index])) { return { *document, item }; - } else if (const auto photo = base::get_if(&items[index])) { + } else if (const auto photo = std::get_if(&items[index])) { return { *photo, item }; } - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } OverlayWidget::Entity OverlayWidget::entityForItemId(const FullMsgId &itemId) const { @@ -3588,9 +3588,9 @@ OverlayWidget::Entity OverlayWidget::entityForItemId(const FullMsgId &itemId) co return { document, item }; } } - return { std::nullopt, item }; + return { v::null, item }; } - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } OverlayWidget::Entity OverlayWidget::entityByIndex(int index) const { @@ -3601,7 +3601,7 @@ OverlayWidget::Entity OverlayWidget::entityByIndex(int index) const { } else if (_collageData) { return entityForCollage(index); } - return { std::nullopt, nullptr }; + return { v::null, nullptr }; } void OverlayWidget::setContext( @@ -3689,7 +3689,7 @@ bool OverlayWidget::moveToEntity(const Entity &entity, int preloadDelta) { } else if (_peer) { setContext(_peer); } else { - setContext(std::nullopt); + setContext(v::null); } clearStreaming(); _streamingStartPaused = false; diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index b14b1e166f..8db91c3ebf 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -1326,7 +1326,7 @@ void Pip::paintPlaybackTexts(QPainter &p) const { void Pip::handleStreamingUpdate(Streaming::Update &&update) { using namespace Streaming; - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { _panel.setAspectRatio( FlipSizeByRotation(update.video.size, _rotation)); }, [&](const PreloadedVideo &update) { diff --git a/Telegram/SourceFiles/mtproto/sender.h b/Telegram/SourceFiles/mtproto/sender.h index c9eaf23fe5..387a1e983f 100644 --- a/Telegram/SourceFiles/mtproto/sender.h +++ b/Telegram/SourceFiles/mtproto/sender.h @@ -162,12 +162,18 @@ class Sender { return std::move(_done); } RPCFailHandlerPtr takeOnFail() { - if (auto handler = base::get_if(&_fail)) { - return std::make_shared>(_sender, std::move(*handler), _failSkipPolicy); - } else if (auto handler = base::get_if(&_fail)) { - return std::make_shared>(_sender, std::move(*handler), _failSkipPolicy); - } - return RPCFailHandlerPtr(); + return v::match(_fail, [&](FailPlainHandler &value) + -> RPCFailHandlerPtr { + return std::make_shared>( + _sender, + std::move(value), + _failSkipPolicy); + }, [&](FailRequestIdHandler &value) -> RPCFailHandlerPtr { + return std::make_shared>( + _sender, + std::move(value), + _failSkipPolicy); + }); } mtpRequestId takeAfter() const noexcept { return _afterRequestId; @@ -185,7 +191,7 @@ class Sender { ShiftedDcId _dcId = 0; crl::time _canWait = 0; RPCDoneHandlerPtr _done; - base::variant _fail; + std::variant _fail; FailSkipPolicy _failSkipPolicy = FailSkipPolicy::Simple; mtpRequestId _afterRequestId = 0; diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.h b/Telegram/SourceFiles/passport/passport_panel_controller.h index beb3b103f2..f0500dc381 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.h +++ b/Telegram/SourceFiles/passport/passport_panel_controller.h @@ -64,7 +64,7 @@ struct ScopeError { // FileKey - file_hash error (bad scan / selfie / translation) // General - general value error (or scan / translation missing) // QString - data_hash with such key error (bad value) - base::variant key; + std::variant key; QString text; }; diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp index 68a45523a6..a9f019e852 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp @@ -37,7 +37,7 @@ constexpr auto kJpegQuality = 89; static_assert(kMaxSize <= Storage::kUseBigFilesFrom); -base::variant ProcessImage(QByteArray &&bytes) { +std::variant ProcessImage(QByteArray &&bytes) { auto image = App::readImage(base::take(bytes)); if (image.isNull()) { return ReadScanError::CantReadImage; @@ -901,10 +901,10 @@ void EditScans::ChooseScan( remainingFiles = std::move(remainingFiles) ]() mutable { auto result = ProcessImage(std::move(bytes)); - if (const auto error = base::get_if(&result)) { + if (const auto error = std::get_if(&result)) { onMainError(*error); } else { - auto content = base::get_if(&result); + auto content = std::get_if(&result); Assert(content != nullptr); crl::on_main([ =, diff --git a/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm b/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm index ebf41a3850..5b625876b2 100644 --- a/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm +++ b/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm @@ -216,7 +216,11 @@ private: }; struct ClearFinish { }; - using ClearTask = base::variant; + using ClearTask = std::variant< + ClearFromHistory, + ClearFromSession, + ClearAll, + ClearFinish>; std::vector _clearingTasks; }; @@ -285,21 +289,20 @@ void Manager::Private::clearingThreadLoop() { auto clearFromSessions = base::flat_set(); { std::unique_lock lock(_clearingMutex); - while (_clearingTasks.empty()) { _clearingCondition.wait(lock); } for (auto &task : _clearingTasks) { - if (base::get_if(&task)) { + v::match(task, [&](ClearFinish) { finished = true; clearAll = true; - } else if (base::get_if(&task)) { + }, [&](ClearAll) { clearAll = true; - } else if (auto fromHistory = base::get_if(&task)) { - clearFromPeers.emplace(fromHistory->fullPeer); - } else if (auto fromSession = base::get_if(&task)) { - clearFromSessions.emplace(fromSession->sessionId); - } + }, [&](const ClearFromHistory &value) { + clearFromPeers.emplace(value.fullPeer); + }, [&](const ClearFromSession &value) { + clearFromSessions.emplace(value.sessionId); + }); } _clearingTasks.clear(); } diff --git a/Telegram/SourceFiles/storage/download_manager_mtproto.cpp b/Telegram/SourceFiles/storage/download_manager_mtproto.cpp index 6c6a590a31..093d4c01e2 100644 --- a/Telegram/SourceFiles/storage/download_manager_mtproto.cpp +++ b/Telegram/SourceFiles/storage/download_manager_mtproto.cpp @@ -442,7 +442,7 @@ Data::FileOrigin DownloadMtprotoTask::fileOrigin() const { } uint64 DownloadMtprotoTask::objectId() const { - if (const auto v = base::get_if(&_location.data)) { + if (const auto v = std::get_if(&_location.data)) { return v->objectId(); } return 0; @@ -456,7 +456,7 @@ void DownloadMtprotoTask::refreshFileReferenceFrom( const Data::UpdatedFileReferences &updates, int requestId, const QByteArray ¤t) { - if (const auto v = base::get_if(&_location.data)) { + if (const auto v = std::get_if(&_location.data)) { v->refreshFileReference(updates); if (v->fileReference() == current) { cancelOnFail(); @@ -525,7 +525,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest( cdnPartFailed(error, id); }).toDC(shiftedDcId).send(); } - return _location.data.match([&](const WebFileLocation &location) { + return v::match(_location.data, [&](const WebFileLocation &location) { return api().request(MTPupload_GetWebFile( MTP_inputWebFileLocation( MTP_bytes(location.url()), diff --git a/Telegram/SourceFiles/storage/download_manager_mtproto.h b/Telegram/SourceFiles/storage/download_manager_mtproto.h index ea4baa44bd..46d91f3e05 100644 --- a/Telegram/SourceFiles/storage/download_manager_mtproto.h +++ b/Telegram/SourceFiles/storage/download_manager_mtproto.h @@ -120,7 +120,7 @@ private: class DownloadMtprotoTask : public base::has_weak_ptr { public: struct Location { - base::variant< + std::variant< StorageFileLocation, WebFileLocation, GeoPointLocation> data; diff --git a/Telegram/SourceFiles/storage/file_download.cpp b/Telegram/SourceFiles/storage/file_download.cpp index d0473049f9..ba0fc2685d 100644 --- a/Telegram/SourceFiles/storage/file_download.cpp +++ b/Telegram/SourceFiles/storage/file_download.cpp @@ -488,7 +488,7 @@ std::unique_ptr CreateFileLoader( bool autoLoading, uint8 cacheTag) { auto result = std::unique_ptr(); - location.data.match([&](const StorageFileLocation &data) { + v::match(location.data, [&](const StorageFileLocation &data) { result = std::make_unique( session, data, diff --git a/Telegram/SourceFiles/storage/file_download_mtproto.cpp b/Telegram/SourceFiles/storage/file_download_mtproto.cpp index 85b3656ee2..05f21985e1 100644 --- a/Telegram/SourceFiles/storage/file_download_mtproto.cpp +++ b/Telegram/SourceFiles/storage/file_download_mtproto.cpp @@ -179,7 +179,7 @@ void mtpFileLoader::cancelHook() { } Storage::Cache::Key mtpFileLoader::cacheKey() const { - return location().data.match([&](const WebFileLocation &location) { + return v::match(location().data, [&](const WebFileLocation &location) { return Data::WebDocumentCacheKey(location); }, [&](const GeoPointLocation &location) { return Data::GeoPointCacheKey(location); diff --git a/Telegram/SourceFiles/storage/file_download_web.cpp b/Telegram/SourceFiles/storage/file_download_web.cpp index b0a8b87f5c..73722eb50d 100644 --- a/Telegram/SourceFiles/storage/file_download_web.cpp +++ b/Telegram/SourceFiles/storage/file_download_web.cpp @@ -44,7 +44,7 @@ struct Progress { qint64 total = 0; }; -using Update = base::variant; +using Update = std::variant; struct UpdateForLoader { not_null loader; @@ -473,9 +473,9 @@ void webFileLoader::startLoading() { _manager->updates( this ) | rpl::start_with_next([=](const Update &data) { - if (const auto progress = base::get_if(&data)) { + if (const auto progress = std::get_if(&data)) { loadProgress(progress->ready, progress->total); - } else if (const auto bytes = base::get_if(&data)) { + } else if (const auto bytes = std::get_if(&data)) { loadFinished(*bytes); } else { loadFailed(); diff --git a/Telegram/SourceFiles/storage/serialize_document.cpp b/Telegram/SourceFiles/storage/serialize_document.cpp index 34638982e2..3e5909995a 100644 --- a/Telegram/SourceFiles/storage/serialize_document.cpp +++ b/Telegram/SourceFiles/storage/serialize_document.cpp @@ -144,7 +144,7 @@ DocumentData *Document::readFromStreamHelper( } } - const auto storage = base::get_if( + const auto storage = std::get_if( &thumb->file().data); if ((stream.status() != QDataStream::Ok) || (!dc && !access) diff --git a/Telegram/SourceFiles/storage/storage_cloud_blob.cpp b/Telegram/SourceFiles/storage/storage_cloud_blob.cpp index d037884c09..91e6b222c8 100644 --- a/Telegram/SourceFiles/storage/storage_cloud_blob.cpp +++ b/Telegram/SourceFiles/storage/storage_cloud_blob.cpp @@ -69,7 +69,7 @@ bool UnpackBlob( } QString StateDescription(const BlobState &state, tr::phrase<> activeText) { - return state.match([](const Available &data) { + return v::match(state, [](const Available &data) { return tr::lng_emoji_set_download( tr::now, lt_size, diff --git a/Telegram/SourceFiles/storage/storage_cloud_blob.h b/Telegram/SourceFiles/storage/storage_cloud_blob.h index d864307e92..2b9e265011 100644 --- a/Telegram/SourceFiles/storage/storage_cloud_blob.h +++ b/Telegram/SourceFiles/storage/storage_cloud_blob.h @@ -65,7 +65,7 @@ struct Failed { }; using Loading = MTP::DedicatedLoader::Progress; -using BlobState = base::variant< +using BlobState = std::variant< Available, Ready, Active, diff --git a/Telegram/SourceFiles/ui/image/image_location.cpp b/Telegram/SourceFiles/ui/image/image_location.cpp index a2a8362d68..5a872490fc 100644 --- a/Telegram/SourceFiles/ui/image/image_location.cpp +++ b/Telegram/SourceFiles/ui/image/image_location.cpp @@ -621,7 +621,7 @@ InMemoryKey inMemoryKey(const InMemoryLocation &location) { } InMemoryKey inMemoryKey(const DownloadLocation &location) { - return location.data.match([](const auto &data) { + return v::match(location.data, [](const auto &data) { return inMemoryKey(data); }); } @@ -681,8 +681,8 @@ std::optional StorageImageLocation::FromSerialized( } QByteArray DownloadLocation::serialize() const { - if (!valid() || data.is()) { - return data.get_unchecked().serialize(); + if (!valid() || v::is(data)) { + return std::get(data).serialize(); } auto result = QByteArray(); auto buffer = QBuffer(&result); @@ -691,7 +691,7 @@ QByteArray DownloadLocation::serialize() const { stream.setVersion(QDataStream::Qt_5_1); stream << quint16(0) << kNonStorageLocationToken; - data.match([&](const StorageFileLocation &data) { + v::match(data, [&](const StorageFileLocation &data) { Unexpected("Variant in DownloadLocation::serialize."); }, [&](const WebFileLocation &data) { stream @@ -718,11 +718,11 @@ QByteArray DownloadLocation::serialize() const { } int DownloadLocation::serializeSize() const { - if (!valid() || data.is()) { - return data.get_unchecked().serializeSize(); + if (!valid() || v::is(data)) { + return std::get(data).serializeSize(); } auto result = sizeof(quint16) + sizeof(quint8) + sizeof(quint8); - data.match([&](const StorageFileLocation &data) { + v::match(data, [&](const StorageFileLocation &data) { Unexpected("Variant in DownloadLocation::serializeSize."); }, [&](const WebFileLocation &data) { result += Serialize::bytearraySize(data.url()) + sizeof(quint64); @@ -809,15 +809,15 @@ DownloadLocation DownloadLocation::convertToModern( StorageFileLocation::Type type, uint64 id, uint64 accessHash) const { - if (!data.is()) { + if (!v::is(data)) { return *this; } - auto &file = data.get_unchecked(); + auto &file = std::get(data); return DownloadLocation{ file.convertToModern(type, id, accessHash) }; } Storage::Cache::Key DownloadLocation::cacheKey() const { - return data.match([](const GeoPointLocation &data) { + return v::match(data, [](const GeoPointLocation &data) { return Data::GeoPointCacheKey(data); }, [](const StorageFileLocation &data) { return data.valid() @@ -837,13 +837,13 @@ Storage::Cache::Key DownloadLocation::cacheKey() const { } Storage::Cache::Key DownloadLocation::bigFileBaseCacheKey() const { - return data.is() - ? data.get_unchecked().bigFileBaseCacheKey() + return v::is(data) + ? std::get(data).bigFileBaseCacheKey() : Storage::Cache::Key(); } bool DownloadLocation::valid() const { - return data.match([](const GeoPointLocation &data) { + return v::match(data, [](const GeoPointLocation &data) { return true; }, [](const StorageFileLocation &data) { return data.valid(); @@ -857,32 +857,32 @@ bool DownloadLocation::valid() const { } bool DownloadLocation::isLegacy() const { - return data.is() - ? data.get_unchecked().isLegacy() + return v::is(data) + ? std::get(data).isLegacy() : false; } QByteArray DownloadLocation::fileReference() const { - if (!data.is()) { + if (!v::is(data)) { return QByteArray(); } - return data.get_unchecked().fileReference(); + return std::get(data).fileReference(); } bool DownloadLocation::refreshFileReference(const QByteArray &data) { - if (!this->data.is()) { + if (!v::is(this->data)) { return false; } - auto &file = this->data.get_unchecked(); + auto &file = std::get(this->data); return file.refreshFileReference(data); } bool DownloadLocation::refreshFileReference( const Data::UpdatedFileReferences &updates) { - if (!data.is()) { + if (!v::is(data)) { return false; } - auto &file = data.get_unchecked(); + auto &file = std::get(data); return file.refreshFileReference(updates); } diff --git a/Telegram/SourceFiles/ui/image/image_location.h b/Telegram/SourceFiles/ui/image/image_location.h index bded985526..2998122051 100644 --- a/Telegram/SourceFiles/ui/image/image_location.h +++ b/Telegram/SourceFiles/ui/image/image_location.h @@ -446,7 +446,7 @@ inline bool operator>=( class DownloadLocation { public: - base::variant< + std::variant< StorageFileLocation, WebFileLocation, GeoPointLocation, diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index b9345bb8f1..1792559c73 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -865,7 +865,7 @@ void UserpicButton::clearStreaming() { void UserpicButton::handleStreamingUpdate(Media::Streaming::Update &&update) { using namespace Media::Streaming; - update.data.match([&](Information &update) { + v::match(update.data, [&](Information &update) { streamingReady(std::move(update)); }, [&](const PreloadedVideo &update) { }, [&](const UpdateVideo &update) { diff --git a/Telegram/SourceFiles/window/window_media_preview.cpp b/Telegram/SourceFiles/window/window_media_preview.cpp index c1c28f6405..c7f7d4aca5 100644 --- a/Telegram/SourceFiles/window/window_media_preview.cpp +++ b/Telegram/SourceFiles/window/window_media_preview.cpp @@ -248,7 +248,7 @@ void MediaPreviewWidget::setupLottie() { _lottie->updates( ) | rpl::start_with_next([=](Lottie::Update update) { - update.data.match([&](const Lottie::Information &) { + v::match(update.data, [&](const Lottie::Information &) { this->update(); }, [&](const Lottie::DisplayFrameRequest &) { this->update(updateArea()); diff --git a/Telegram/lib_base b/Telegram/lib_base index e94515700a..0060349806 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit e94515700a622c2424f58d32e670581e9185f7e7 +Subproject commit 0060349806529cd517201bec2d25208ad8d0bb89 diff --git a/Telegram/lib_lottie b/Telegram/lib_lottie index b666e438be..b060b25b45 160000 --- a/Telegram/lib_lottie +++ b/Telegram/lib_lottie @@ -1 +1 @@ -Subproject commit b666e438be285b2781d93ac64138ab32ab4a85e0 +Subproject commit b060b25b45bf0100ae6d35f558eb0818380ebc13 diff --git a/Telegram/lib_rpl b/Telegram/lib_rpl index b58d2804ac..e654c5ee98 160000 --- a/Telegram/lib_rpl +++ b/Telegram/lib_rpl @@ -1 +1 @@ -Subproject commit b58d2804acda906119c53c1fa1a2593fa9895878 +Subproject commit e654c5ee98199b47a426aaaf6a1f7331aca0ebcd diff --git a/Telegram/lib_storage b/Telegram/lib_storage index 538a72e5d3..52b8d0456f 160000 --- a/Telegram/lib_storage +++ b/Telegram/lib_storage @@ -1 +1 @@ -Subproject commit 538a72e5d3aedb660d3a399cc883067ada16e9cf +Subproject commit 52b8d0456fec25f80ca96e6d354dd7583f7fa350