From 2e5a0e056cdb40d61d487c6062bffe1a835f6ddd Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 21 Sep 2018 19:28:46 +0300 Subject: [PATCH] Move to std::optional. --- Telegram/SourceFiles/apiwrap.cpp | 12 +-- Telegram/SourceFiles/apiwrap.h | 6 +- Telegram/SourceFiles/base/flat_map.h | 4 +- Telegram/SourceFiles/base/optional.h | 94 ++++--------------- Telegram/SourceFiles/base/variant.h | 21 +++++ .../SourceFiles/boxes/add_contact_box.cpp | 12 +-- .../boxes/peers/edit_peer_info_box.cpp | 16 ++-- Telegram/SourceFiles/boxes/report_box.h | 2 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 4 +- .../SourceFiles/chat_helpers/stickers.cpp | 12 +-- Telegram/SourceFiles/chat_helpers/stickers.h | 2 +- .../chat_helpers/stickers_list_widget.cpp | 8 +- .../SourceFiles/core/core_cloud_password.cpp | 16 ++-- Telegram/SourceFiles/core/launcher.h | 4 +- Telegram/SourceFiles/core/update_checker.cpp | 50 +++++----- Telegram/SourceFiles/data/data_feed.cpp | 4 +- Telegram/SourceFiles/data/data_feed.h | 4 +- Telegram/SourceFiles/data/data_messages.cpp | 30 +++--- Telegram/SourceFiles/data/data_messages.h | 32 +++---- .../SourceFiles/data/data_notify_settings.cpp | 60 ++++++------ .../SourceFiles/data/data_notify_settings.h | 8 +- Telegram/SourceFiles/data/data_peer.h | 8 +- .../SourceFiles/data/data_peer_values.cpp | 8 +- .../data/data_search_controller.cpp | 2 +- .../SourceFiles/data/data_search_controller.h | 4 +- Telegram/SourceFiles/data/data_session.cpp | 4 +- Telegram/SourceFiles/data/data_session.h | 4 +- .../SourceFiles/data/data_shared_media.cpp | 46 ++++----- Telegram/SourceFiles/data/data_shared_media.h | 50 +++++----- Telegram/SourceFiles/data/data_sparse_ids.cpp | 62 ++++++------ Telegram/SourceFiles/data/data_sparse_ids.h | 64 ++++++------- .../SourceFiles/data/data_user_photos.cpp | 34 +++---- Telegram/SourceFiles/data/data_user_photos.h | 22 ++--- .../export/data/export_data_types.cpp | 8 +- .../export/data/export_data_types.h | 4 +- .../SourceFiles/export/export_api_wrap.cpp | 14 +-- Telegram/SourceFiles/export/export_api_wrap.h | 2 +- .../export/output/export_output_file.cpp | 2 +- .../export/output/export_output_file.h | 2 +- .../export/output/export_output_html.cpp | 8 +- .../export/output/export_output_json.cpp | 4 +- .../export/output/export_output_text.cpp | 4 +- .../history/feed/history_feed_section.cpp | 14 +-- .../history/feed/history_feed_section.h | 4 +- Telegram/SourceFiles/history/history.cpp | 4 +- Telegram/SourceFiles/history/history.h | 12 +-- .../SourceFiles/history/history_widget.cpp | 6 +- Telegram/SourceFiles/history/history_widget.h | 2 +- .../history/view/history_view_list_widget.cpp | 8 +- .../history/view/history_view_list_widget.h | 6 +- .../info/feed/info_feed_channels.h | 2 +- .../info/media/info_media_list_widget.cpp | 10 +- .../info/media/info_media_list_widget.h | 4 +- .../info/media/info_media_widget.cpp | 4 +- .../info/media/info_media_widget.h | 2 +- .../info/profile/info_profile_button.cpp | 2 +- .../info/profile/info_profile_button.h | 4 +- .../info/profile/info_profile_members.h | 2 +- .../media/player/media_player_instance.cpp | 10 +- .../media/player/media_player_instance.h | 10 +- .../media/view/media_view_group_thumbs.cpp | 4 +- Telegram/SourceFiles/mediaview.cpp | 70 +++++++------- Telegram/SourceFiles/mediaview.h | 20 ++-- Telegram/SourceFiles/messenger.cpp | 4 +- Telegram/SourceFiles/messenger.h | 2 +- Telegram/SourceFiles/mtproto/mtp_instance.cpp | 12 +-- .../passport/passport_encryption.h | 2 +- .../passport/passport_form_controller.cpp | 22 ++--- .../passport/passport_form_controller.h | 12 +-- .../passport_form_view_controller.cpp | 2 +- .../passport/passport_panel_controller.cpp | 34 +++---- .../passport/passport_panel_controller.h | 16 ++-- .../passport/passport_panel_details_row.cpp | 14 +-- .../passport/passport_panel_details_row.h | 2 +- .../passport/passport_panel_edit_document.cpp | 10 +- .../passport/passport_panel_edit_document.h | 10 +- .../passport/passport_panel_edit_scans.cpp | 20 ++-- .../passport/passport_panel_edit_scans.h | 10 +- .../platform/mac/specific_mac_p.mm | 2 +- .../SourceFiles/platform/win/launcher_win.cpp | 4 +- .../SourceFiles/platform/win/launcher_win.h | 2 +- Telegram/SourceFiles/rpl/combine.h | 12 +-- Telegram/SourceFiles/rpl/combine_previous.h | 2 +- .../SourceFiles/rpl/distinct_until_changed.h | 2 +- Telegram/SourceFiles/rpl/filter.h | 6 +- Telegram/SourceFiles/stdafx.h | 1 + .../cache/storage_cache_binlog_reader.cpp | 2 +- .../cache/storage_cache_binlog_reader.h | 2 +- .../cache/storage_cache_database_object.cpp | 4 +- .../cache/storage_cache_database_object.h | 4 +- .../storage/cache/storage_cache_types.cpp | 6 +- .../storage/cache/storage_cache_types.h | 2 +- .../SourceFiles/storage/file_download.cpp | 6 +- Telegram/SourceFiles/storage/file_download.h | 6 +- .../SourceFiles/storage/localimageloader.h | 2 +- Telegram/SourceFiles/storage/localstorage.cpp | 4 +- .../storage/storage_encrypted_file.cpp | 2 +- .../storage/storage_encrypted_file.h | 2 +- .../storage/storage_feed_messages.cpp | 2 +- .../storage/storage_shared_media.h | 4 +- .../storage/storage_sparse_ids_list.cpp | 10 +- .../storage/storage_sparse_ids_list.h | 14 +-- .../storage/storage_user_photos.cpp | 4 +- .../SourceFiles/storage/storage_user_photos.h | 12 +-- Telegram/SourceFiles/ui/images.cpp | 16 ++-- Telegram/SourceFiles/ui/images.h | 8 +- Telegram/SourceFiles/ui/special_buttons.cpp | 2 +- Telegram/SourceFiles/ui/widgets/buttons.cpp | 2 +- Telegram/SourceFiles/ui/widgets/buttons.h | 4 +- Telegram/SourceFiles/ui/widgets/checkbox.cpp | 4 +- Telegram/SourceFiles/ui/widgets/checkbox.h | 8 +- .../SourceFiles/ui/widgets/input_fields.cpp | 2 +- .../SourceFiles/ui/widgets/input_fields.h | 2 +- .../window/window_lock_widgets.cpp | 6 +- .../SourceFiles/window/window_lock_widgets.h | 2 +- 115 files changed, 632 insertions(+), 672 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index abd5783fc..a95bfa20e 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1927,7 +1927,7 @@ void ApiWrap::handlePrivacyChange( mtpTypeId keyTypeId, const MTPVector &rules) { using Key = Privacy::Key; - const auto key = [&]() -> base::optional { + const auto key = [&]() -> std::optional { switch (keyTypeId) { case mtpc_privacyKeyStatusTimestamp: case mtpc_inputPrivacyKeyStatusTimestamp: return Key::LastSeen; @@ -1936,7 +1936,7 @@ void ApiWrap::handlePrivacyChange( case mtpc_privacyKeyPhoneCall: case mtpc_inputPrivacyKeyPhoneCall: return Key::Calls; } - return base::none; + return std::nullopt; }(); if (!key) { return; @@ -2582,7 +2582,7 @@ void ApiWrap::refreshFileReference( request( MTPmessages_GetSavedGifs(MTP_int(0)), [] { crl::on_main([] { Local::writeSavedGifs(); }); }); - }, [&](base::none_type) { + }, [&](std::nullopt_t) { fail(); }); } @@ -4236,7 +4236,7 @@ void ApiWrap::sendUploadedPhoto( void ApiWrap::sendUploadedDocument( FullMsgId localId, const MTPInputFile &file, - const base::optional &thumb, + const std::optional &thumb, bool silent) { if (const auto item = App::histItemById(localId)) { auto media = item->media(); @@ -4987,10 +4987,10 @@ rpl::producer ApiWrap::passwordState() const { } auto ApiWrap::passwordStateCurrent() const -->base::optional { +->std::optional { return _passwordState ? base::make_optional(*_passwordState) - : base::none; + : std::nullopt; } void ApiWrap::saveSelfBio(const QString &text, FnMut done) { diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 8fcc195ed..c37f3fbaa 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -304,7 +304,7 @@ public: void sendUploadedDocument( FullMsgId localId, const MTPInputFile &file, - const base::optional &thumb, + const std::optional &thumb, bool silent); void cancelLocalItem(not_null item); @@ -336,7 +336,7 @@ public: void reloadPasswordState(); void clearUnconfirmedPassword(); rpl::producer passwordState() const; - base::optional passwordStateCurrent() const; + std::optional passwordStateCurrent() const; void saveSelfBio(const QString &text, FnMut done); @@ -717,7 +717,7 @@ private: std::map> _privacyChanges; mtpRequestId _selfDestructRequestId = 0; - base::optional _selfDestructDays; + std::optional _selfDestructDays; rpl::event_stream _selfDestructChanges; }; diff --git a/Telegram/SourceFiles/base/flat_map.h b/Telegram/SourceFiles/base/flat_map.h index 307f77edc..00480b022 100644 --- a/Telegram/SourceFiles/base/flat_map.h +++ b/Telegram/SourceFiles/base/flat_map.h @@ -722,10 +722,10 @@ public: return where->second; } - optional take(const Key &key) { + std::optional take(const Key &key) { auto it = find(key); if (it == this->end()) { - return base::none; + return std::nullopt; } auto result = std::move(it->second); this->erase(it); diff --git a/Telegram/SourceFiles/base/optional.h b/Telegram/SourceFiles/base/optional.h index 8fb16e903..2628ee5bb 100644 --- a/Telegram/SourceFiles/base/optional.h +++ b/Telegram/SourceFiles/base/optional.h @@ -7,39 +7,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include #include #include "base/variant.h" namespace base { -struct none_type { - bool operator==(none_type other) const { - return true; - } - bool operator!=(none_type other) const { - return false; - } - bool operator<(none_type other) const { - return false; - } - bool operator<=(none_type other) const { - return true; - } - bool operator>(none_type other) const { - return false; - } - bool operator>=(none_type other) const { - return true; - } - -}; - -constexpr none_type none = {}; - template class optional_variant { public: - optional_variant() : _impl(none) { + optional_variant() : _impl(std::nullopt) { } optional_variant(const optional_variant &other) : _impl(other._impl) { } @@ -63,7 +40,7 @@ public: } bool has_value() const { - return !is(); + return !is(); } explicit operator bool() const { return has_value(); @@ -93,7 +70,7 @@ public: return get_unchecked(); } void clear() { - _impl.template set(); + _impl.template set(); } template @@ -119,7 +96,7 @@ public: } private: - variant _impl; + variant _impl; }; @@ -147,17 +124,14 @@ inline decltype(auto) match( return value.match(std::forward(methods)...); } -template -class optional; - template struct optional_wrap_once { - using type = optional; + using type = std::optional; }; template -struct optional_wrap_once> { - using type = optional; +struct optional_wrap_once> { + using type = std::optional; }; template @@ -176,58 +150,22 @@ struct optional_chain_result { template using optional_chain_result_t = typename optional_chain_result::type; -template -class optional : public optional_variant { - using parent = optional_variant; - -public: - using parent::parent; - - Type &operator*() & { - Expects(parent::template is()); - - return parent::template get_unchecked(); - } - Type &&operator*() && { - Expects(parent::template is()); - - return std::move(parent::template get_unchecked()); - } - const Type &operator*() const & { - Expects(parent::template is()); - - return parent::template get_unchecked(); - } - Type *operator->() { - Expects(parent::template is()); - - return std::addressof(parent::template get_unchecked()); - } - const Type *operator->() const { - Expects(parent::template is()); - - return std::addressof(parent::template get_unchecked()); - } - template - Type &emplace(Args &&...args) { - return parent::template set(std::forward(args)...); - } - -}; - template optional_wrap_once_t make_optional(Type &&value) { return optional_wrap_once_t { std::forward(value) }; } +} // namespace base + template -inline auto operator|(const optional &value, Method method) --> optional_chain_result_t { +inline auto operator|(const std::optional &value, Method method) +-> base::optional_chain_result_t { if constexpr (std::is_same_v) { return value ? (method(*value), true) : false; } else { - return value ? make_optional(method(*value)) : none; + return value + ? base::optional_chain_result_t( + method(*value)) + : std::nullopt; } } - -} // namespace base diff --git a/Telegram/SourceFiles/base/variant.h b/Telegram/SourceFiles/base/variant.h index 058724b6c..e8539d4d2 100644 --- a/Telegram/SourceFiles/base/variant.h +++ b/Telegram/SourceFiles/base/variant.h @@ -7,6 +7,27 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include + +inline bool operator<(std::nullopt_t, std::nullopt_t) { + return false; +} +inline bool operator>(std::nullopt_t, std::nullopt_t) { + return false; +} +inline bool operator<=(std::nullopt_t, std::nullopt_t) { + return true; +} +inline bool operator>=(std::nullopt_t, std::nullopt_t) { + return true; +} +inline bool operator==(std::nullopt_t, std::nullopt_t) { + return true; +} +inline bool operator!=(std::nullopt_t, std::nullopt_t) { + return false; +} + #include #include #include "base/match_method.h" diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index d037eaf9d..47fb03517 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -414,7 +414,7 @@ void GroupInfoBox::createGroup(not_null selectUsersBox, const QStr App::main()->sentUpdatesReceived(result); auto success = base::make_optional(&result) - | [](auto updates) -> base::optional*> { + | [](auto updates) -> std::optional*> { switch (updates->type()) { case mtpc_updates: return &updates->c_updates().vchats.v; @@ -422,12 +422,12 @@ void GroupInfoBox::createGroup(not_null selectUsersBox, const QStr return &updates->c_updatesCombined().vchats.v; } LOG(("API Error: unexpected update cons %1 (GroupInfoBox::creationDone)").arg(updates->type())); - return base::none; + return std::nullopt; } | [](auto chats) { return (!chats->empty() && chats->front().type() == mtpc_chat) ? base::make_optional(chats) - : base::none; + : std::nullopt; } | [](auto chats) { return App::chat(chats->front().c_chat().vid.v); @@ -517,7 +517,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio App::main()->sentUpdatesReceived(result); auto success = base::make_optional(&result) - | [](auto updates) -> base::optional*> { + | [](auto updates) -> std::optional*> { switch (updates->type()) { case mtpc_updates: return &updates->c_updates().vchats.v; @@ -525,12 +525,12 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio return &updates->c_updatesCombined().vchats.v; } LOG(("API Error: unexpected update cons %1 (GroupInfoBox::createChannel)").arg(updates->type())); - return base::none; + return std::nullopt; } | [](auto chats) { return (!chats->empty() && chats->front().type() == mtpc_channel) ? base::make_optional(chats) - : base::none; + : std::nullopt; } | [](auto chats) { return App::channel(chats->front().c_channel().vid.v); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 9962d5bbf..0d16bffb3 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -93,12 +93,12 @@ private: Ui::Checkbox *signatures = nullptr; }; struct Saving { - base::optional username; - base::optional title; - base::optional description; - base::optional hiddenPreHistory; - base::optional signatures; - base::optional everyoneInvites; + std::optional username; + std::optional title; + std::optional description; + std::optional hiddenPreHistory; + std::optional signatures; + std::optional everyoneInvites; }; Fn computeTitle() const; @@ -143,7 +143,7 @@ private: void revokeInviteLink(); void exportInviteLink(const QString &confirmation); - base::optional validate() const; + std::optional validate() const; bool validateUsername(Saving &to) const; bool validateTitle(Saving &to) const; bool validateDescription(Saving &to) const; @@ -1087,7 +1087,7 @@ void Controller::submitDescription() { } } -base::optional Controller::validate() const { +std::optional Controller::validate() const { auto result = Saving(); if (validateUsername(result) && validateTitle(result) diff --git a/Telegram/SourceFiles/boxes/report_box.h b/Telegram/SourceFiles/boxes/report_box.h index efdb6d90e..0e7162929 100644 --- a/Telegram/SourceFiles/boxes/report_box.h +++ b/Telegram/SourceFiles/boxes/report_box.h @@ -44,7 +44,7 @@ private: bool reportFail(const RPCError &error); not_null _peer; - base::optional _ids; + std::optional _ids; std::shared_ptr> _reasonGroup; object_ptr> _reasonSpam = { nullptr }; diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 31f3c93c0..7ffc590bf 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -136,7 +136,7 @@ private: void drawSimpleFrame(Painter &p, QRect to, QSize size) const; Ui::GroupMediaLayout _layout; - base::optional _animateFromGeometry; + std::optional _animateFromGeometry; const QImage _fullPreview; const int _shrinkSize = 0; QPixmap _albumImage; @@ -229,7 +229,7 @@ AlbumThumb::AlbumThumb( } void AlbumThumb::resetLayoutAnimation() { - _animateFromGeometry = base::none; + _animateFromGeometry = std::nullopt; } void AlbumThumb::animateLayoutToInitial() { diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index df60f785d..2342ff164 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -239,7 +239,7 @@ void MoveFavedToFront(Set &set, int index) { void RequestSetToPushFaved(not_null document); -void SetIsFaved(not_null document, base::optional>> emojiList = base::none) { +void SetIsFaved(not_null document, std::optional>> emojiList = std::nullopt) { auto &sets = Auth().data().stickerSetsRef(); auto it = sets.find(FavedSetId); if (it == sets.end()) { @@ -825,17 +825,17 @@ std::vector> GetListByEmoji( }) | ranges::to_vector; } -base::optional>> GetEmojiListFromSet( +std::optional>> GetEmojiListFromSet( not_null document) { if (auto sticker = document->sticker()) { auto &inputSet = sticker->set; if (inputSet.type() != mtpc_inputStickerSetID) { - return base::none; + return std::nullopt; } auto &sets = Auth().data().stickerSets(); auto it = sets.constFind(inputSet.c_inputStickerSetID().vid.v); if (it == sets.cend()) { - return base::none; + return std::nullopt; } auto result = std::vector>(); for (auto i = it->emoji.cbegin(), e = it->emoji.cend(); i != e; ++i) { @@ -844,11 +844,11 @@ base::optional>> GetEmojiListFromSet( } } if (result.empty()) { - return base::none; + return std::nullopt; } return std::move(result); } - return base::none; + return std::nullopt; } Set *FeedSet(const MTPDstickerSet &set) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers.h b/Telegram/SourceFiles/chat_helpers/stickers.h index d378dfe6e..e5820e3d8 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.h +++ b/Telegram/SourceFiles/chat_helpers/stickers.h @@ -89,7 +89,7 @@ void GifsReceived(const QVector &items, int32 hash); std::vector> GetListByEmoji( not_null emoji, uint64 seed); -base::optional>> GetEmojiListFromSet( +std::optional>> GetEmojiListFromSet( not_null document); Set *FeedSet(const MTPDstickerSet &data); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 7d403b83b..e9588370c 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1498,7 +1498,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) { _previewTimer.stop(); auto pressed = _pressed; - setPressed(base::none); + setPressed(std::nullopt); if (pressed != _selected) { update(); } @@ -1652,8 +1652,8 @@ void StickersListWidget::enterFromChildEvent(QEvent *e, QWidget *child) { } void StickersListWidget::clearSelection() { - setPressed(base::none); - setSelected(base::none); + setPressed(std::nullopt); + setSelected(std::nullopt); update(); } @@ -2058,7 +2058,7 @@ void StickersListWidget::updateSelected() { return; } - auto newSelected = OverState { base::none }; + auto newSelected = OverState { std::nullopt }; 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 22918ba77..97f71ada0 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( - base::none_type, + std::nullopt_t, bytes::const_span password) { Unexpected("Bad secure secret algorithm."); } @@ -203,7 +203,7 @@ CloudPasswordCheckRequest ParseCloudPasswordCheckRequest( CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) { if (!parsed.is()) { - return base::none; + return std::nullopt; } auto &value = parsed.get_unchecked(); const auto already = value.salt1.size(); @@ -219,7 +219,7 @@ MTPPasswordKdfAlgo PrepareCloudPasswordAlgo(const CloudPasswordAlgo &data) { MTP_bytes(data.salt2), MTP_int(data.g), MTP_bytes(data.p)); - }, [](base::none_type) { + }, [](std::nullopt_t) { return MTP_passwordKdfAlgoUnknown(); }); } @@ -233,7 +233,7 @@ bytes::vector ComputeCloudPasswordHash( bytes::const_span password) { return algo.match([&](const CloudPasswordAlgoModPow &data) { return ComputeHash(data, password); - }, [](base::none_type) -> bytes::vector { + }, [](std::nullopt_t) -> bytes::vector { Unexpected("Bad cloud password algorithm."); }); } @@ -243,7 +243,7 @@ CloudPasswordDigest ComputeCloudPasswordDigest( bytes::const_span password) { return algo.match([&](const CloudPasswordAlgoModPow &data) { return ComputeDigest(data, password); - }, [](base::none_type) -> CloudPasswordDigest { + }, [](std::nullopt_t) -> CloudPasswordDigest { Unexpected("Bad cloud password algorithm."); }); } @@ -253,7 +253,7 @@ CloudPasswordResult ComputeCloudPasswordCheck( bytes::const_span hash) { return request.algo.match([&](const CloudPasswordAlgoModPow &data) { return ComputeCheck(request, data, hash); - }, [](base::none_type) -> CloudPasswordResult { + }, [](std::nullopt_t) -> CloudPasswordResult { Unexpected("Bad cloud password algorithm."); }); } @@ -274,7 +274,7 @@ SecureSecretAlgo ParseSecureSecretAlgo( SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) { if (!parsed.is()) { - return base::none; + return std::nullopt; } auto &value = parsed.get_unchecked(); const auto already = value.salt.size(); @@ -290,7 +290,7 @@ MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo( MTP_bytes(data.salt)); }, [](const SecureSecretAlgoSHA512 &data) { return MTP_securePasswordKdfAlgoSHA512(MTP_bytes(data.salt)); - }, [](base::none_type) { + }, [](std::nullopt_t) { return MTP_securePasswordKdfAlgoUnknown(); }); } diff --git a/Telegram/SourceFiles/core/launcher.h b/Telegram/SourceFiles/core/launcher.h index 54575749c..df1b4836f 100644 --- a/Telegram/SourceFiles/core/launcher.h +++ b/Telegram/SourceFiles/core/launcher.h @@ -41,10 +41,10 @@ private: void processArguments(); QStringList readArguments(int argc, char *argv[]) const; - virtual base::optional readArgumentsHook( + virtual std::optional readArgumentsHook( int argc, char *argv[]) const { - return base::none; + return std::nullopt; } void init(); diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index d8bbe1e5c..ec29b2023 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -158,9 +158,9 @@ private: void gotFailure(QNetworkReply::NetworkError e); void clearSentRequest(); bool handleResponse(const QByteArray &response); - base::optional parseOldResponse( + std::optional parseOldResponse( const QByteArray &response) const; - base::optional parseResponse(const QByteArray &response) const; + std::optional parseResponse(const QByteArray &response) const; QString validateLatestUrl( uint64 availableVersion, bool isAvailableBeta, @@ -262,14 +262,14 @@ private: const QString &username, Fn callback); void gotMessage(const MTPmessages_Messages &result); - base::optional parseMessage( + std::optional parseMessage( const MTPmessages_Messages &result) const; - base::optional parseText(const QByteArray &text) const; + std::optional parseText(const QByteArray &text) const; FileLocation validateLatestLocation( uint64 availableVersion, const FileLocation &location) const; void gotFile(const MTPmessages_Messages &result); - base::optional parseFile( + std::optional parseFile( const MTPmessages_Messages &result) const; MtpWeak _mtp; @@ -597,7 +597,7 @@ bool UnpackUpdate(const QString &filepath) { return true; } -base::optional ExtractChannel( +std::optional ExtractChannel( const MTPcontacts_ResolvedPeer &result) { const auto &data = result.c_contacts_resolvedPeer(); if (const auto peer = peerFromMTP(data.vpeer)) { @@ -612,7 +612,7 @@ base::optional ExtractChannel( } } } - return base::none; + return std::nullopt; } template @@ -717,11 +717,11 @@ bool ParseCommonMap( return true; } -base::optional GetMessagesElement( +std::optional GetMessagesElement( const MTPmessages_Messages &list) { - const auto get = [](auto &&data) -> base::optional { + const auto get = [](auto &&data) -> std::optional { return data.vmessages.v.isEmpty() - ? base::none + ? std::nullopt : base::make_optional(data.vmessages.v[0]); }; switch (list.type()) { @@ -732,7 +732,7 @@ base::optional GetMessagesElement( case mtpc_messages_channelMessages: return get(list.c_messages_channelMessages()); case mtpc_messages_messagesNotModified: - return base::none; + return std::nullopt; default: Unexpected("Type of messages.Messages (GetMessagesElement)"); } } @@ -961,14 +961,14 @@ void HttpChecker::gotFailure(QNetworkReply::NetworkError e) { fail(); } -base::optional HttpChecker::parseOldResponse( +std::optional HttpChecker::parseOldResponse( const QByteArray &response) const { const auto string = QString::fromLatin1(response); const auto old = QRegularExpression( qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$") ).match(string); if (!old.hasMatch()) { - return base::none; + return std::nullopt; } const auto availableVersion = old.captured(1).toULongLong(); const auto url = old.captured(2); @@ -979,7 +979,7 @@ base::optional HttpChecker::parseOldResponse( isAvailableBeta ? url.mid(5) + "_{signature}" : url); } -base::optional HttpChecker::parseResponse( +std::optional HttpChecker::parseResponse( const QByteArray &response) const { auto bestAvailableVersion = 0ULL; auto bestIsAvailableBeta = false; @@ -1005,7 +1005,7 @@ base::optional HttpChecker::parseResponse( }; const auto result = ParseCommonMap(response, testing(), accumulate); if (!result) { - return base::none; + return std::nullopt; } return validateLatestUrl( bestAvailableVersion, @@ -1350,17 +1350,17 @@ void MtpChecker::gotMessage(const MTPmessages_Messages &result) { } auto MtpChecker::parseMessage(const MTPmessages_Messages &result) const --> base::optional { +-> std::optional { const auto message = GetMessagesElement(result); if (!message || message->type() != mtpc_message) { LOG(("Update Error: MTP feed message not found.")); - return base::none; + return std::nullopt; } return parseText(message->c_message().vmessage.v); } auto MtpChecker::parseText(const QByteArray &text) const --> base::optional { +-> std::optional { auto bestAvailableVersion = 0ULL; auto bestLocation = FileLocation(); const auto accumulate = [&]( @@ -1404,7 +1404,7 @@ auto MtpChecker::parseText(const QByteArray &text) const }; const auto result = ParseCommonMap(text, testing(), accumulate); if (!result) { - return base::none; + return std::nullopt; } return validateLatestLocation(bestAvailableVersion, bestLocation); } @@ -1430,23 +1430,23 @@ void MtpChecker::gotFile(const MTPmessages_Messages &result) { } auto MtpChecker::parseFile(const MTPmessages_Messages &result) const --> base::optional { +-> std::optional { const auto message = GetMessagesElement(result); if (!message || message->type() != mtpc_message) { LOG(("Update Error: MTP file message not found.")); - return base::none; + return std::nullopt; } const auto &data = message->c_message(); if (!data.has_media() || data.vmedia.type() != mtpc_messageMediaDocument) { LOG(("Update Error: MTP file media not found.")); - return base::none; + return std::nullopt; } const auto &document = data.vmedia.c_messageMediaDocument(); if (!document.has_document() || document.vdocument.type() != mtpc_document) { LOG(("Update Error: MTP file not found.")); - return base::none; + return std::nullopt; } const auto &fields = document.vdocument.c_document(); const auto name = [&] { @@ -1460,12 +1460,12 @@ auto MtpChecker::parseFile(const MTPmessages_Messages &result) const }(); if (name.isEmpty()) { LOG(("Update Error: MTP file name not found.")); - return base::none; + return std::nullopt; } const auto size = fields.vsize.v; if (size <= 0) { LOG(("Update Error: MTP file size is invalid.")); - return base::none; + return std::nullopt; } const auto location = MTP_inputDocumentFileLocation( fields.vid, diff --git a/Telegram/SourceFiles/data/data_feed.cpp b/Telegram/SourceFiles/data/data_feed.cpp index 330e8db3f..14df12f17 100644 --- a/Telegram/SourceFiles/data/data_feed.cpp +++ b/Telegram/SourceFiles/data/data_feed.cpp @@ -250,7 +250,7 @@ void Feed::changeChannelsList( // After that we restore it. const auto oldLastMessage = base::take(_lastMessage); for (const auto channel : add) { - _lastMessage = base::none; + _lastMessage = std::nullopt; channel->setFeed(this); } _lastMessage = oldLastMessage; @@ -282,7 +282,7 @@ void Feed::historyCleared(not_null history) { } void Feed::recountLastMessage() { - _lastMessage = base::none; + _lastMessage = std::nullopt; for (const auto history : _channels) { if (!history->lastMessageKnown()) { _parent->session().api().requestDialogEntry(this); diff --git a/Telegram/SourceFiles/data/data_feed.h b/Telegram/SourceFiles/data/data_feed.h index d587316dc..1cdf30e2f 100644 --- a/Telegram/SourceFiles/data/data_feed.h +++ b/Telegram/SourceFiles/data/data_feed.h @@ -103,10 +103,10 @@ private: QString _name; base::flat_set _nameWords; base::flat_set _nameFirstLetters; - base::optional _lastMessage; + std::optional _lastMessage; rpl::variable _unreadPosition; - base::optional _unreadCount; + std::optional _unreadCount; rpl::event_stream _unreadCountChanges; int _unreadMutedCount = 0; diff --git a/Telegram/SourceFiles/data/data_messages.cpp b/Telegram/SourceFiles/data/data_messages.cpp index 460389469..e8837a731 100644 --- a/Telegram/SourceFiles/data/data_messages.cpp +++ b/Telegram/SourceFiles/data/data_messages.cpp @@ -93,7 +93,7 @@ template void MessagesList::addRange( const Range &messages, MessagesRange noSkipRange, - base::optional count, + std::optional count, bool incrementCount) { Expects(!count || !incrementCount); @@ -119,13 +119,13 @@ void MessagesList::addRange( void MessagesList::addNew(MessagePosition messageId) { auto range = { messageId }; - addRange(range, { messageId, MaxMessagePosition }, base::none, true); + addRange(range, { messageId, MaxMessagePosition }, std::nullopt, true); } void MessagesList::addSlice( std::vector &&messageIds, MessagesRange noSkipRange, - base::optional count) { + std::optional count) { addRange(messageIds, noSkipRange, count); } @@ -167,7 +167,7 @@ void MessagesList::removeAll(ChannelId channelId) { void MessagesList::invalidate() { _slices.clear(); - _count = base::none; + _count = std::nullopt; } void MessagesList::invalidateBottom() { @@ -181,7 +181,7 @@ void MessagesList::invalidateBottom() { }); } } - _count = base::none; + _count = std::nullopt; } rpl::producer MessagesList::query( @@ -272,10 +272,10 @@ bool MessagesSliceBuilder::applyUpdate(const MessagesSliceUpdate &update) { } auto skippedBefore = (update.range.from == MinMessagePosition) ? 0 - : base::optional {}; + : std::optional {}; auto skippedAfter = (update.range.till == MaxMessagePosition) ? 0 - : base::optional {}; + : std::optional {}; mergeSliceData( update.count, needMergeMessages @@ -331,20 +331,20 @@ bool MessagesSliceBuilder::removeFromChannel(ChannelId channelId) { ++i; } } - _skippedBefore = _skippedAfter = base::none; + _skippedBefore = _skippedAfter = std::nullopt; checkInsufficient(); return true; } bool MessagesSliceBuilder::invalidated() { - _fullCount = _skippedBefore = _skippedAfter = base::none; + _fullCount = _skippedBefore = _skippedAfter = std::nullopt; _ids.clear(); checkInsufficient(); return false; } bool MessagesSliceBuilder::bottomInvalidated() { - _fullCount = _skippedAfter = base::none; + _fullCount = _skippedAfter = std::nullopt; checkInsufficient(); return true; } @@ -354,10 +354,10 @@ void MessagesSliceBuilder::checkInsufficient() { } void MessagesSliceBuilder::mergeSliceData( - base::optional count, + std::optional count, const base::flat_set &messageIds, - base::optional skippedBefore, - base::optional skippedAfter) { + std::optional skippedBefore, + std::optional skippedAfter) { if (messageIds.empty()) { if (count && _fullCount != count) { _fullCount = count; @@ -388,7 +388,7 @@ void MessagesSliceBuilder::mergeSliceData( } else if (wasMinId != impossible && _skippedBefore) { adjustSkippedBefore(wasMinId, *_skippedBefore); } else { - _skippedBefore = base::none; + _skippedBefore = std::nullopt; } auto adjustSkippedAfter = [&](MessagePosition oldId, int oldSkippedAfter) { @@ -402,7 +402,7 @@ void MessagesSliceBuilder::mergeSliceData( } else if (wasMaxId != impossible && _skippedAfter) { adjustSkippedAfter(wasMaxId, *_skippedAfter); } else { - _skippedAfter = base::none; + _skippedAfter = std::nullopt; } fillSkippedAndSliceToLimits(); } diff --git a/Telegram/SourceFiles/data/data_messages.h b/Telegram/SourceFiles/data/data_messages.h index 8c511b0b8..98c214d70 100644 --- a/Telegram/SourceFiles/data/data_messages.h +++ b/Telegram/SourceFiles/data/data_messages.h @@ -93,9 +93,9 @@ constexpr auto UnreadMessagePosition = MessagePosition( struct MessagesSlice { std::vector ids; - base::optional skippedBefore; - base::optional skippedAfter; - base::optional fullCount; + std::optional skippedBefore; + std::optional skippedAfter; + std::optional fullCount; }; @@ -116,16 +116,16 @@ struct MessagesQuery { }; struct MessagesResult { - base::optional count; - base::optional skippedBefore; - base::optional skippedAfter; + std::optional count; + std::optional skippedBefore; + std::optional skippedAfter; base::flat_set messageIds; }; struct MessagesSliceUpdate { const base::flat_set *messages = nullptr; MessagesRange range; - base::optional count; + std::optional count; }; class MessagesList { @@ -134,7 +134,7 @@ public: void addSlice( std::vector &&messageIds, MessagesRange noSkipRange, - base::optional count); + std::optional count); void removeOne(MessagePosition messageId); void removeAll(ChannelId channelId); void invalidate(); @@ -178,14 +178,14 @@ private: void addRange( const Range &messages, MessagesRange noSkipRange, - base::optional count, + std::optional count, bool incrementCount = false); MessagesResult queryFromSlice( const MessagesQuery &query, const Slice &slice) const; - base::optional _count; + std::optional _count; base::flat_set _slices; rpl::event_stream _sliceUpdated; @@ -234,17 +234,17 @@ private: void sliceToLimits(); void mergeSliceData( - base::optional count, + std::optional count, const base::flat_set &messageIds, - base::optional skippedBefore = base::none, - base::optional skippedAfter = base::none); + std::optional skippedBefore = std::nullopt, + std::optional skippedAfter = std::nullopt); MessagePosition _key; base::flat_set _ids; MessagesRange _range; - base::optional _fullCount; - base::optional _skippedBefore; - base::optional _skippedAfter; + std::optional _fullCount; + std::optional _skippedBefore; + std::optional _skippedAfter; int _limitBefore = 0; int _limitAfter = 0; diff --git a/Telegram/SourceFiles/data/data_notify_settings.cpp b/Telegram/SourceFiles/data/data_notify_settings.cpp index fe34be35f..dd950472e 100644 --- a/Telegram/SourceFiles/data/data_notify_settings.cpp +++ b/Telegram/SourceFiles/data/data_notify_settings.cpp @@ -28,24 +28,24 @@ public: bool change(const MTPDpeerNotifySettings &data); bool change( - base::optional muteForSeconds, - base::optional silentPosts); + std::optional muteForSeconds, + std::optional silentPosts); - base::optional muteUntil() const; - base::optional silentPosts() const; + std::optional muteUntil() const; + std::optional silentPosts() const; MTPinputPeerNotifySettings serialize() const; private: bool change( - base::optional mute, - base::optional sound, - base::optional showPreviews, - base::optional silentPosts); + std::optional mute, + std::optional sound, + std::optional showPreviews, + std::optional silentPosts); - base::optional _mute; - base::optional _sound; - base::optional _silent; - base::optional _showPreviews; + std::optional _mute; + std::optional _sound; + std::optional _silent; + std::optional _showPreviews; }; @@ -57,18 +57,18 @@ NotifySettingsValue::NotifySettingsValue( bool NotifySettingsValue::change(const MTPDpeerNotifySettings &data) { return change(data.has_mute_until() ? base::make_optional(data.vmute_until.v) - : base::none, data.has_sound() + : std::nullopt, data.has_sound() ? base::make_optional(qs(data.vsound)) - : base::none, data.has_show_previews() + : std::nullopt, data.has_show_previews() ? base::make_optional(mtpIsTrue(data.vshow_previews)) - : base::none, data.has_silent() + : std::nullopt, data.has_silent() ? base::make_optional(mtpIsTrue(data.vsilent)) - : base::none); + : std::nullopt); } bool NotifySettingsValue::change( - base::optional muteForSeconds, - base::optional silentPosts) { + std::optional muteForSeconds, + std::optional silentPosts) { const auto now = unixtime(); const auto notMuted = muteForSeconds ? !(*muteForSeconds) @@ -92,10 +92,10 @@ bool NotifySettingsValue::change( } bool NotifySettingsValue::change( - base::optional mute, - base::optional sound, - base::optional showPreviews, - base::optional silentPosts) { + std::optional mute, + std::optional sound, + std::optional showPreviews, + std::optional silentPosts) { if (_mute == mute && _sound == sound && _showPreviews == showPreviews @@ -109,11 +109,11 @@ bool NotifySettingsValue::change( return true; } -base::optional NotifySettingsValue::muteUntil() const { +std::optional NotifySettingsValue::muteUntil() const { return _mute; } -base::optional NotifySettingsValue::silentPosts() const { +std::optional NotifySettingsValue::silentPosts() const { return _silent; } @@ -157,8 +157,8 @@ bool NotifySettings::change(const MTPPeerNotifySettings &settings) { } bool NotifySettings::change( - base::optional muteForSeconds, - base::optional silentPosts) { + std::optional muteForSeconds, + std::optional silentPosts) { if (!muteForSeconds && !silentPosts) { return false; } else if (_value) { @@ -178,20 +178,20 @@ bool NotifySettings::change( MTPstring())); } -base::optional NotifySettings::muteUntil() const { +std::optional NotifySettings::muteUntil() const { return _value ? _value->muteUntil() - : base::none; + : std::nullopt; } bool NotifySettings::settingsUnknown() const { return !_known; } -base::optional NotifySettings::silentPosts() const { +std::optional NotifySettings::silentPosts() const { return _value ? _value->silentPosts() - : base::none; + : std::nullopt; } MTPinputPeerNotifySettings NotifySettings::serialize() const { diff --git a/Telegram/SourceFiles/data/data_notify_settings.h b/Telegram/SourceFiles/data/data_notify_settings.h index bdce3fb27..dc61df588 100644 --- a/Telegram/SourceFiles/data/data_notify_settings.h +++ b/Telegram/SourceFiles/data/data_notify_settings.h @@ -19,12 +19,12 @@ public: bool change(const MTPPeerNotifySettings &settings); bool change( - base::optional muteForSeconds, - base::optional silentPosts); + std::optional muteForSeconds, + std::optional silentPosts); bool settingsUnknown() const; - base::optional muteUntil() const; - base::optional silentPosts() const; + std::optional muteUntil() const; + std::optional silentPosts() const; MTPinputPeerNotifySettings serialize() const; ~NotifySettings(); diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 789b3810d..3d9902464 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -68,21 +68,21 @@ public: bool isVerified() const; bool isMegagroup() const; - base::optional notifyMuteUntil() const { + std::optional notifyMuteUntil() const { return _notify.muteUntil(); } bool notifyChange(const MTPPeerNotifySettings &settings) { return _notify.change(settings); } bool notifyChange( - base::optional muteForSeconds, - base::optional silentPosts) { + std::optional muteForSeconds, + std::optional silentPosts) { return _notify.change(muteForSeconds, silentPosts); } bool notifySettingsUnknown() const { return _notify.settingsUnknown(); } - base::optional notifySilentPosts() const { + std::optional notifySilentPosts() const { return _notify.silentPosts(); } MTPinputPeerNotifySettings notifySerialize() const { diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index 2f3e849a8..4bee82f7f 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -39,7 +39,7 @@ int OnlinePhraseChangeInSeconds(TimeId online, TimeId now) { return std::max(static_cast(nowFull.secsTo(tomorrow)), 0); } -base::optional OnlineTextSpecial(not_null user) { +std::optional OnlineTextSpecial(not_null user) { if (isNotificationsUser(user->id)) { return lang(lng_status_service_notifications); } else if (user->botInfo) { @@ -47,10 +47,10 @@ base::optional OnlineTextSpecial(not_null user) { } else if (isServiceUser(user->id)) { return lang(lng_status_support); } - return base::none; + return std::nullopt; } -base::optional OnlineTextCommon(TimeId online, TimeId now) { +std::optional OnlineTextCommon(TimeId online, TimeId now) { if (online <= 0) { switch (online) { case 0: @@ -65,7 +65,7 @@ base::optional OnlineTextCommon(TimeId online, TimeId now) { } else if (online > now) { return lang(lng_status_online); } - return base::none; + return std::nullopt; } } // namespace diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp index 1c753ed72..6fe2a7734 100644 --- a/Telegram/SourceFiles/data/data_search_controller.cpp +++ b/Telegram/SourceFiles/data/data_search_controller.cpp @@ -180,7 +180,7 @@ SearchController::CacheEntry::CacheEntry(const Query &query) : peerData(App::peer(query.peerId)) , migratedData(query.migratedPeerId ? base::make_optional(Data(App::peer(query.migratedPeerId))) - : base::none) { + : std::nullopt) { } bool SearchController::hasInCache(const Query &query) const { diff --git a/Telegram/SourceFiles/data/data_search_controller.h b/Telegram/SourceFiles/data/data_search_controller.h index ec31dc66b..172d41206 100644 --- a/Telegram/SourceFiles/data/data_search_controller.h +++ b/Telegram/SourceFiles/data/data_search_controller.h @@ -64,7 +64,7 @@ public: struct SavedState { Query query; IdsList peerList; - base::optional migratedList; + std::optional migratedList; }; void setQuery(const Query &query); @@ -100,7 +100,7 @@ private: CacheEntry(const Query &query); Data peerData; - base::optional migratedData; + std::optional migratedData; }; struct CacheLess { diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 812921543..37536d510 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -1842,8 +1842,8 @@ void Session::applyNotifySetting( void Session::updateNotifySettings( not_null peer, - base::optional muteForSeconds, - base::optional silentPosts) { + std::optional muteForSeconds, + std::optional silentPosts) { if (peer->notifyChange(muteForSeconds, silentPosts)) { updateNotifySettingsLocal(peer); _session->api().updateNotifySettingsDelayed(peer); diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 8c9d49e0d..c20db99df 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -396,8 +396,8 @@ public: const MTPPeerNotifySettings &settings); void updateNotifySettings( not_null peer, - base::optional muteForSeconds, - base::optional silentPosts = base::none); + std::optional muteForSeconds, + std::optional silentPosts = std::nullopt); bool notifyIsMuted( not_null peer, TimeMs *changesIn = nullptr) const; diff --git a/Telegram/SourceFiles/data/data_shared_media.cpp b/Telegram/SourceFiles/data/data_shared_media.cpp index 66dd5be51..038ac55f4 100644 --- a/Telegram/SourceFiles/data/data_shared_media.cpp +++ b/Telegram/SourceFiles/data/data_shared_media.cpp @@ -30,7 +30,7 @@ using Type = Storage::SharedMediaType; } // namespace -base::optional SharedMediaOverviewType( +std::optional SharedMediaOverviewType( Storage::SharedMediaType type) { switch (type) { case Type::Photo: @@ -40,7 +40,7 @@ base::optional SharedMediaOverviewType( case Type::VoiceFile: case Type::Link: return type; } - return base::none; + return std::nullopt; } void SharedMediaShowOverview( @@ -177,7 +177,7 @@ SharedMediaWithLastSlice::SharedMediaWithLastSlice(Key key) SharedMediaWithLastSlice::SharedMediaWithLastSlice( Key key, SparseIdsMergedSlice slice, - base::optional ending) + std::optional ending) : _key(key) , _slice(std::move(slice)) , _ending(std::move(ending)) @@ -187,21 +187,21 @@ SharedMediaWithLastSlice::SharedMediaWithLastSlice( : false) { } -base::optional SharedMediaWithLastSlice::fullCount() const { +std::optional SharedMediaWithLastSlice::fullCount() const { return Add( _slice.fullCount(), _isolatedLastPhoto | [](bool isolated) { return isolated ? 1 : 0; }); } -base::optional SharedMediaWithLastSlice::skippedBeforeImpl() const { +std::optional SharedMediaWithLastSlice::skippedBeforeImpl() const { return _slice.skippedBefore(); } -base::optional SharedMediaWithLastSlice::skippedBefore() const { +std::optional SharedMediaWithLastSlice::skippedBefore() const { return _reversed ? skippedAfterImpl() : skippedBeforeImpl(); } -base::optional SharedMediaWithLastSlice::skippedAfterImpl() const { +std::optional SharedMediaWithLastSlice::skippedAfterImpl() const { return isolatedInSlice() ? Add( _slice.skippedAfter(), @@ -209,21 +209,21 @@ base::optional SharedMediaWithLastSlice::skippedAfterImpl() const { : (lastPhotoSkip() | [](int) { return 0; }); } -base::optional SharedMediaWithLastSlice::skippedAfter() const { +std::optional SharedMediaWithLastSlice::skippedAfter() const { return _reversed ? skippedBeforeImpl() : skippedAfterImpl(); } -base::optional SharedMediaWithLastSlice::indexOfImpl(Value value) const { +std::optional SharedMediaWithLastSlice::indexOfImpl(Value value) const { return base::get_if(&value) ? _slice.indexOf(*base::get_if(&value)) : (isolatedInSlice() || !_lastPhotoId || (*base::get_if>(&value))->id != *_lastPhotoId) - ? base::none + ? std::nullopt : Add(_slice.size() - 1, lastPhotoSkip()); } -base::optional SharedMediaWithLastSlice::indexOf(Value value) const { +std::optional SharedMediaWithLastSlice::indexOf(Value value) const { const auto result = indexOfImpl(value); if (result && (*result < 0 || *result >= size())) { // Should not happen. @@ -296,7 +296,7 @@ SharedMediaWithLastSlice::Value SharedMediaWithLastSlice::operator[](int index) : Value(Auth().data().photo(*_lastPhotoId)); } -base::optional SharedMediaWithLastSlice::distance( +std::optional SharedMediaWithLastSlice::distance( const Key &a, const Key &b) const { if (auto i = indexOf(ComputeId(a))) { @@ -304,29 +304,29 @@ base::optional SharedMediaWithLastSlice::distance( return *j - *i; } } - return base::none; + return std::nullopt; } void SharedMediaWithLastSlice::reverse() { _reversed = !_reversed; } -base::optional SharedMediaWithLastSlice::LastPeerPhotoId( +std::optional SharedMediaWithLastSlice::LastPeerPhotoId( PeerId peerId) { if (auto peer = App::peerLoaded(peerId)) { return peer->userpicPhotoUnknown() - ? base::none + ? std::nullopt : base::make_optional(peer->userpicPhotoId()); } - return base::none; + return std::nullopt; } -base::optional SharedMediaWithLastSlice::IsLastIsolated( +std::optional SharedMediaWithLastSlice::IsLastIsolated( const SparseIdsMergedSlice &slice, - const base::optional &ending, - base::optional lastPeerPhotoId) { + const std::optional &ending, + std::optional lastPeerPhotoId) { if (!lastPeerPhotoId) { - return base::none; + return std::nullopt; } else if (!*lastPeerPhotoId) { return false; } @@ -338,12 +338,12 @@ base::optional SharedMediaWithLastSlice::IsLastIsolated( | [&](PhotoId photoId) { return *lastPeerPhotoId != photoId; }; } -base::optional SharedMediaWithLastSlice::LastFullMsgId( +std::optional SharedMediaWithLastSlice::LastFullMsgId( const SparseIdsMergedSlice &slice) { if (slice.fullCount() == 0) { return FullMsgId(); } else if (slice.size() == 0 || slice.skippedAfter() != 0) { - return base::none; + return std::nullopt; } return slice[slice.size() - 1]; } @@ -364,7 +364,7 @@ rpl::producer SharedMediaWithLastViewer( consumer.put_next(SharedMediaWithLastSlice( key, std::move(update), - base::none)); + std::nullopt)); }); } return rpl::combine( diff --git a/Telegram/SourceFiles/data/data_shared_media.h b/Telegram/SourceFiles/data/data_shared_media.h index 548d4412e..28f745c9b 100644 --- a/Telegram/SourceFiles/data/data_shared_media.h +++ b/Telegram/SourceFiles/data/data_shared_media.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/weak_ptr.h" #include "data/data_sparse_ids.h" -base::optional SharedMediaOverviewType( +std::optional SharedMediaOverviewType( Storage::SharedMediaType type); void SharedMediaShowOverview( Storage::SharedMediaType type, @@ -93,15 +93,15 @@ public: SharedMediaWithLastSlice( Key key, SparseIdsMergedSlice slice, - base::optional ending); + std::optional ending); - base::optional fullCount() const; - base::optional skippedBefore() const; - base::optional skippedAfter() const; - base::optional indexOf(Value fullId) const; + std::optional fullCount() const; + std::optional skippedBefore() const; + std::optional skippedAfter() const; + std::optional indexOf(Value fullId) const; int size() const; Value operator[](int index) const; - base::optional distance(const Key &a, const Key &b) const; + std::optional distance(const Key &a, const Key &b) const; void reverse(); @@ -123,23 +123,23 @@ public: } private: - static base::optional EndingSlice(const Key &key) { + static std::optional EndingSlice(const Key &key) { return base::get_if(&key.universalId) ? base::make_optional(SparseIdsMergedSlice(EndingKey(key))) - : base::none; + : std::nullopt; } - static base::optional LastPeerPhotoId(PeerId peerId); - static base::optional IsLastIsolated( + static std::optional LastPeerPhotoId(PeerId peerId); + static std::optional IsLastIsolated( const SparseIdsMergedSlice &slice, - const base::optional &ending, - base::optional lastPeerPhotoId); - static base::optional LastFullMsgId( + const std::optional &ending, + std::optional lastPeerPhotoId); + static std::optional LastFullMsgId( const SparseIdsMergedSlice &slice); - static base::optional Add( - const base::optional &a, - const base::optional &b) { - return (a && b) ? base::make_optional(*a + *b) : base::none; + static std::optional Add( + const std::optional &a, + const std::optional &b) { + return (a && b) ? base::make_optional(*a + *b) : std::nullopt; } static Value ComputeId(PeerId peerId, MsgId msgId) { return FullMsgId( @@ -158,20 +158,20 @@ private: bool isolatedInSlice() const { return (_slice.skippedAfter() != 0); } - base::optional lastPhotoSkip() const { + std::optional lastPhotoSkip() const { return _isolatedLastPhoto | [](bool isolated) { return isolated ? 1 : 0; }; } - base::optional skippedBeforeImpl() const; - base::optional skippedAfterImpl() const; - base::optional indexOfImpl(Value fullId) const; + std::optional skippedBeforeImpl() const; + std::optional skippedAfterImpl() const; + std::optional indexOfImpl(Value fullId) const; Key _key; SparseIdsMergedSlice _slice; - base::optional _ending; - base::optional _lastPhotoId; - base::optional _isolatedLastPhoto; + std::optional _ending; + std::optional _lastPhotoId; + std::optional _isolatedLastPhoto; bool _reversed = false; }; diff --git a/Telegram/SourceFiles/data/data_sparse_ids.cpp b/Telegram/SourceFiles/data/data_sparse_ids.cpp index e75aa4ca1..4f58b6aad 100644 --- a/Telegram/SourceFiles/data/data_sparse_ids.cpp +++ b/Telegram/SourceFiles/data/data_sparse_ids.cpp @@ -13,9 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL SparseIdsSlice::SparseIdsSlice( const base::flat_set &ids, MsgRange range, - base::optional fullCount, - base::optional skippedBefore, - base::optional skippedAfter) + std::optional fullCount, + std::optional skippedBefore, + std::optional skippedAfter) : _ids(ids) , _range(range) , _fullCount(fullCount) @@ -23,12 +23,12 @@ SparseIdsSlice::SparseIdsSlice( , _skippedAfter(skippedAfter) { } -base::optional SparseIdsSlice::indexOf(MsgId msgId) const { +std::optional SparseIdsSlice::indexOf(MsgId msgId) const { auto it = _ids.find(msgId); if (it != _ids.end()) { return (it - _ids.begin()); } - return base::none; + return std::nullopt; } MsgId SparseIdsSlice::operator[](int index) const { @@ -37,7 +37,7 @@ MsgId SparseIdsSlice::operator[](int index) const { return *(_ids.begin() + index); } -base::optional SparseIdsSlice::distance( +std::optional SparseIdsSlice::distance( MsgId a, MsgId b) const { if (auto i = indexOf(a)) { @@ -45,14 +45,14 @@ base::optional SparseIdsSlice::distance( return *j - *i; } } - return base::none; + return std::nullopt; } -base::optional SparseIdsSlice::nearest(MsgId msgId) const { +std::optional SparseIdsSlice::nearest(MsgId msgId) const { if (auto it = ranges::lower_bound(_ids, msgId); it != _ids.end()) { return *it; } else if (_ids.empty()) { - return base::none; + return std::nullopt; } return _ids.back(); } @@ -67,19 +67,19 @@ SparseIdsMergedSlice::SparseIdsMergedSlice(Key key) SparseIdsMergedSlice::SparseIdsMergedSlice( Key key, SparseIdsSlice part, - base::optional migrated) + std::optional migrated) : _key(key) , _part(std::move(part)) , _migrated(std::move(migrated)) { } -base::optional SparseIdsMergedSlice::fullCount() const { +std::optional SparseIdsMergedSlice::fullCount() const { return Add( _part.fullCount(), _migrated ? _migrated->fullCount() : 0); } -base::optional SparseIdsMergedSlice::skippedBefore() const { +std::optional SparseIdsMergedSlice::skippedBefore() const { return Add( isolatedInMigrated() ? 0 : _part.skippedBefore(), _migrated @@ -90,22 +90,22 @@ base::optional SparseIdsMergedSlice::skippedBefore() const { ); } -base::optional SparseIdsMergedSlice::skippedAfter() const { +std::optional SparseIdsMergedSlice::skippedAfter() const { return Add( isolatedInMigrated() ? _part.fullCount() : _part.skippedAfter(), isolatedInPart() ? 0 : _migrated->skippedAfter() ); } -base::optional SparseIdsMergedSlice::indexOf( +std::optional SparseIdsMergedSlice::indexOf( FullMsgId fullId) const { return isFromPart(fullId) ? (_part.indexOf(fullId.msg) | func::add(migratedSize())) : isolatedInPart() - ? base::none + ? std::nullopt : isFromMigrated(fullId) ? _migrated->indexOf(fullId.msg) - : base::none; + : std::nullopt; } int SparseIdsMergedSlice::size() const { @@ -125,7 +125,7 @@ FullMsgId SparseIdsMergedSlice::operator[](int index) const { return ComputeId(_key.peerId, _part[index]); } -base::optional SparseIdsMergedSlice::distance( +std::optional SparseIdsMergedSlice::distance( const Key &a, const Key &b) const { if (auto i = indexOf(ComputeId(a))) { @@ -133,11 +133,11 @@ base::optional SparseIdsMergedSlice::distance( return *j - *i; } } - return base::none; + return std::nullopt; } auto SparseIdsMergedSlice::nearest( - UniversalMsgId id) const -> base::optional { + UniversalMsgId id) const -> std::optional { auto convertFromPartNearest = [&](MsgId result) { return ComputeId(_key.peerId, result); }; @@ -149,18 +149,18 @@ auto SparseIdsMergedSlice::nearest( return partNearestId | convertFromPartNearest; } else if (isolatedInPart()) { - return base::none; + return std::nullopt; } return _migrated->nearest(ServerMaxMsgId - 1) | convertFromMigratedNearest; } if (auto migratedNearestId = _migrated ? _migrated->nearest(id + ServerMaxMsgId) - : base::none) { + : std::nullopt) { return migratedNearestId | convertFromMigratedNearest; } else if (isolatedInMigrated()) { - return base::none; + return std::nullopt; } return _part.nearest(0) | convertFromPartNearest; @@ -201,10 +201,10 @@ bool SparseIdsSliceBuilder::applyUpdate( } auto skippedBefore = (update.range.from == 0) ? 0 - : base::optional {}; + : std::optional {}; auto skippedAfter = (update.range.till == ServerMaxMsgId) ? 0 - : base::optional {}; + : std::optional {}; mergeSliceData( update.count, needMergeMessages @@ -253,7 +253,7 @@ bool SparseIdsSliceBuilder::removeAll() { } bool SparseIdsSliceBuilder::invalidateBottom() { - _fullCount = _skippedAfter = base::none; + _fullCount = _skippedAfter = std::nullopt; if (_range.till == ServerMaxMsgId) { _range.till = _ids.empty() ? _range.from : _ids.back(); } @@ -266,10 +266,10 @@ void SparseIdsSliceBuilder::checkInsufficient() { } void SparseIdsSliceBuilder::mergeSliceData( - base::optional count, + std::optional count, const base::flat_set &messageIds, - base::optional skippedBefore, - base::optional skippedAfter) { + std::optional skippedBefore, + std::optional skippedAfter) { if (messageIds.empty()) { if (count && _fullCount != count) { _fullCount = count; @@ -299,7 +299,7 @@ void SparseIdsSliceBuilder::mergeSliceData( } else if (wasMinId >= 0 && _skippedBefore) { adjustSkippedBefore(wasMinId, *_skippedBefore); } else { - _skippedBefore = base::none; + _skippedBefore = std::nullopt; } auto adjustSkippedAfter = [&](MsgId oldId, int oldSkippedAfter) { @@ -313,7 +313,7 @@ void SparseIdsSliceBuilder::mergeSliceData( } else if (wasMaxId >= 0 && _skippedAfter) { adjustSkippedAfter(wasMaxId, *_skippedAfter); } else { - _skippedAfter = base::none; + _skippedAfter = std::nullopt; } fillSkippedAndSliceToLimits(); } @@ -420,7 +420,7 @@ rpl::producer SparseIdsMergedSlice::CreateViewer( consumer.put_next(SparseIdsMergedSlice( key, std::move(part), - base::none)); + std::nullopt)); }); } auto migratedViewer = simpleViewer( diff --git a/Telegram/SourceFiles/data/data_sparse_ids.h b/Telegram/SourceFiles/data/data_sparse_ids.h index 3198d4748..a01b2fa1b 100644 --- a/Telegram/SourceFiles/data/data_sparse_ids.h +++ b/Telegram/SourceFiles/data/data_sparse_ids.h @@ -22,25 +22,25 @@ public: SparseIdsSlice( const base::flat_set &ids, MsgRange range, - base::optional fullCount, - base::optional skippedBefore, - base::optional skippedAfter); + std::optional fullCount, + std::optional skippedBefore, + std::optional skippedAfter); - base::optional fullCount() const { return _fullCount; } - base::optional skippedBefore() const { return _skippedBefore; } - base::optional skippedAfter() const { return _skippedAfter; } - base::optional indexOf(MsgId msgId) const; + std::optional fullCount() const { return _fullCount; } + std::optional skippedBefore() const { return _skippedBefore; } + std::optional skippedAfter() const { return _skippedAfter; } + std::optional indexOf(MsgId msgId) const; int size() const { return _ids.size(); } MsgId operator[](int index) const; - base::optional distance(MsgId a, MsgId b) const; - base::optional nearest(MsgId msgId) const; + std::optional distance(MsgId a, MsgId b) const; + std::optional nearest(MsgId msgId) const; private: base::flat_set _ids; MsgRange _range; - base::optional _fullCount; - base::optional _skippedBefore; - base::optional _skippedAfter; + std::optional _fullCount; + std::optional _skippedBefore; + std::optional _skippedAfter; }; @@ -76,16 +76,16 @@ public: SparseIdsMergedSlice( Key key, SparseIdsSlice part, - base::optional migrated); + std::optional migrated); - base::optional fullCount() const; - base::optional skippedBefore() const; - base::optional skippedAfter() const; - base::optional indexOf(FullMsgId fullId) const; + std::optional fullCount() const; + std::optional skippedBefore() const; + std::optional skippedAfter() const; + std::optional indexOf(FullMsgId fullId) const; int size() const; FullMsgId operator[](int index) const; - base::optional distance(const Key &a, const Key &b) const; - base::optional nearest(UniversalMsgId id) const; + std::optional distance(const Key &a, const Key &b) const; + std::optional nearest(UniversalMsgId id) const; using SimpleViewerFunction = rpl::producer( PeerId peerId, @@ -107,10 +107,10 @@ private: ? (ServerMaxMsgId + key.universalId) : (key.universalId > 0) ? (ServerMaxMsgId - 1) : 0; } - static base::optional MigratedSlice(const Key &key) { + static std::optional MigratedSlice(const Key &key) { return key.migratedPeerId ? base::make_optional(SparseIdsSlice()) - : base::none; + : std::nullopt; } static bool IsFromSlice(PeerId peerId, FullMsgId fullId) { @@ -128,10 +128,10 @@ private: ? ComputeId(key.peerId, key.universalId) : ComputeId(key.migratedPeerId, ServerMaxMsgId + key.universalId); } - static base::optional Add( - const base::optional &a, - const base::optional &b) { - return (a && b) ? base::make_optional(*a + *b) : base::none; + static std::optional Add( + const std::optional &a, + const std::optional &b) { + return (a && b) ? base::make_optional(*a + *b) : std::nullopt; } bool isFromPart(FullMsgId fullId) const { @@ -156,7 +156,7 @@ private: Key _key; SparseIdsSlice _part; - base::optional _migrated; + std::optional _migrated; }; @@ -200,17 +200,17 @@ private: void sliceToLimits(); void mergeSliceData( - base::optional count, + std::optional count, const base::flat_set &messageIds, - base::optional skippedBefore = base::none, - base::optional skippedAfter = base::none); + std::optional skippedBefore = std::nullopt, + std::optional skippedAfter = std::nullopt); Key _key; base::flat_set _ids; MsgRange _range; - base::optional _fullCount; - base::optional _skippedBefore; - base::optional _skippedAfter; + std::optional _fullCount; + std::optional _skippedBefore; + std::optional _skippedAfter; int _limitBefore = 0; int _limitAfter = 0; diff --git a/Telegram/SourceFiles/data/data_user_photos.cpp b/Telegram/SourceFiles/data/data_user_photos.cpp index e97473243..d9c0ee1c7 100644 --- a/Telegram/SourceFiles/data/data_user_photos.cpp +++ b/Telegram/SourceFiles/data/data_user_photos.cpp @@ -29,16 +29,16 @@ public: private: void mergeSliceData( - base::optional count, + std::optional count, const std::deque &photoIds, - base::optional skippedBefore, + std::optional skippedBefore, int skippedAfter); void sliceToLimits(); Key _key; std::deque _ids; - base::optional _fullCount; - base::optional _skippedBefore; + std::optional _fullCount; + std::optional _skippedBefore; int _skippedAfter = 0; int _limitBefore = 0; int _limitAfter = 0; @@ -51,17 +51,17 @@ UserPhotosSlice::UserPhotosSlice(Key key) : UserPhotosSlice( key, {}, - base::none, - base::none, - base::none) { + std::nullopt, + std::nullopt, + std::nullopt) { } UserPhotosSlice::UserPhotosSlice( Key key, std::deque &&ids, - base::optional fullCount, - base::optional skippedBefore, - base::optional skippedAfter) + std::optional fullCount, + std::optional skippedBefore, + std::optional skippedAfter) : _key(key) , _ids(std::move(ids)) , _fullCount(fullCount) @@ -74,12 +74,12 @@ void UserPhotosSlice::reverse() { std::swap(_skippedBefore, _skippedAfter); } -base::optional UserPhotosSlice::indexOf(PhotoId photoId) const { +std::optional UserPhotosSlice::indexOf(PhotoId photoId) const { auto it = ranges::find(_ids, photoId); if (it != _ids.end()) { return (it - _ids.begin()); } - return base::none; + return std::nullopt; } PhotoId UserPhotosSlice::operator[](int index) const { @@ -88,17 +88,17 @@ PhotoId UserPhotosSlice::operator[](int index) const { return *(_ids.begin() + index); } -base::optional UserPhotosSlice::distance(const Key &a, const Key &b) const { +std::optional UserPhotosSlice::distance(const Key &a, const Key &b) const { if (a.userId != _key.userId || b.userId != _key.userId) { - return base::none; + return std::nullopt; } if (auto i = indexOf(a.photoId)) { if (auto j = indexOf(b.photoId)) { return *j - *i; } } - return base::none; + return std::nullopt; } UserPhotosSliceBuilder::UserPhotosSliceBuilder( @@ -137,9 +137,9 @@ void UserPhotosSliceBuilder::checkInsufficientPhotos() { } void UserPhotosSliceBuilder::mergeSliceData( - base::optional count, + std::optional count, const std::deque &photoIds, - base::optional skippedBefore, + std::optional skippedBefore, int skippedAfter) { if (photoIds.empty()) { if (_fullCount != count) { diff --git a/Telegram/SourceFiles/data/data_user_photos.h b/Telegram/SourceFiles/data/data_user_photos.h index 7b2c860d1..13ea740e0 100644 --- a/Telegram/SourceFiles/data/data_user_photos.h +++ b/Telegram/SourceFiles/data/data_user_photos.h @@ -18,28 +18,28 @@ public: UserPhotosSlice( Key key, std::deque &&ids, - base::optional fullCount, - base::optional skippedBefore, - base::optional skippedAfter); + std::optional fullCount, + std::optional skippedBefore, + std::optional skippedAfter); void reverse(); const Key &key() const { return _key; } - base::optional fullCount() const { return _fullCount; } - base::optional skippedBefore() const { return _skippedBefore; } - base::optional skippedAfter() const { return _skippedAfter; } - base::optional indexOf(PhotoId msgId) const; + std::optional fullCount() const { return _fullCount; } + std::optional skippedBefore() const { return _skippedBefore; } + std::optional skippedAfter() const { return _skippedAfter; } + std::optional indexOf(PhotoId msgId) const; int size() const { return _ids.size(); } PhotoId operator[](int index) const; - base::optional distance(const Key &a, const Key &b) const; + std::optional distance(const Key &a, const Key &b) const; private: Key _key; std::deque _ids; - base::optional _fullCount; - base::optional _skippedBefore; - base::optional _skippedAfter; + std::optional _fullCount; + std::optional _skippedBefore; + std::optional _skippedAfter; friend class UserPhotosSliceBuilder; diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index e079d3eb2..54798914c 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -529,8 +529,8 @@ std::pair WriteImageThumb( const QString &basePath, const QString &largePath, Fn convertSize, - base::optional format, - base::optional quality, + std::optional format, + std::optional quality, const QString &postfix) { if (largePath.isEmpty()) { return {}; @@ -582,8 +582,8 @@ QString WriteImageThumb( basePath, largePath, [=](QSize size) { return QSize(width, height); }, - base::none, - base::none, + std::nullopt, + std::nullopt, postfix).first; } diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index b9437e136..fb6e03f84 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -87,8 +87,8 @@ std::pair WriteImageThumb( const QString &basePath, const QString &largePath, Fn convertSize, - base::optional format = base::none, - base::optional quality = base::none, + std::optional format = std::nullopt, + std::optional quality = std::nullopt, const QString &postfix = "_thumb"); QString WriteImageThumb( diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index c882ba8fe..dee4a0949 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -97,7 +97,7 @@ public: LoadedFileCache(int limit); void save(const Location &location, const QString &relativePath); - base::optional find(const Location &location) const; + std::optional find(const Location &location) const; private: int _limit = 0; @@ -135,7 +135,7 @@ struct ApiWrap::UserpicsProcess { FnMut finish; int processed = 0; - base::optional slice; + std::optional slice; uint64 maxId = 0; bool lastSlice = false; int fileIndex = 0; @@ -207,7 +207,7 @@ struct ApiWrap::ChatProcess { int32 largestIdPlusOne = 1; Data::ParseMediaContext context; - base::optional slice; + std::optional slice; bool lastSlice = false; int fileIndex = 0; }; @@ -309,16 +309,16 @@ void ApiWrap::LoadedFileCache::save( } } -base::optional ApiWrap::LoadedFileCache::find( +std::optional ApiWrap::LoadedFileCache::find( const Location &location) const { if (!location) { - return base::none; + return std::nullopt; } const auto key = ComputeLocationKey(location); if (const auto i = _map.find(key); i != end(_map)) { return i->second; } - return base::none; + return std::nullopt; } ApiWrap::FileProcess::FileProcess(const QString &path, Output::Stats *stats) @@ -954,7 +954,7 @@ void ApiWrap::requestMessagesCount(int localSplitIndex) { } void ApiWrap::finishExport(FnMut done) { - const auto guard = gsl::finally([&] { _takeoutId = base::none; }); + const auto guard = gsl::finally([&] { _takeoutId = std::nullopt; }); mainRequest(MTPaccount_FinishTakeoutSession( MTP_flags(MTPaccount_FinishTakeoutSession::Flag::f_success) diff --git a/Telegram/SourceFiles/export/export_api_wrap.h b/Telegram/SourceFiles/export/export_api_wrap.h index 7e3d64e19..991008746 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.h +++ b/Telegram/SourceFiles/export/export_api_wrap.h @@ -191,7 +191,7 @@ private: void ioError(const Output::Result &result); MTP::ConcurrentSender _mtp; - base::optional _takeoutId; + std::optional _takeoutId; Output::Stats *_stats = nullptr; std::unique_ptr _settings; diff --git a/Telegram/SourceFiles/export/output/export_output_file.cpp b/Telegram/SourceFiles/export/output/export_output_file.cpp index 1d56ce471..544bdbcdf 100644 --- a/Telegram/SourceFiles/export/output/export_output_file.cpp +++ b/Telegram/SourceFiles/export/output/export_output_file.cpp @@ -32,7 +32,7 @@ bool File::empty() const { Result File::writeBlock(const QByteArray &block) { const auto result = writeBlockAttempt(block); if (!result) { - _file.clear(); + _file.reset(); } return result; } diff --git a/Telegram/SourceFiles/export/output/export_output_file.h b/Telegram/SourceFiles/export/output/export_output_file.h index 33bf5bf4b..3516e4983 100644 --- a/Telegram/SourceFiles/export/output/export_output_file.h +++ b/Telegram/SourceFiles/export/output/export_output_file.h @@ -46,7 +46,7 @@ private: QString _path; int _offset = 0; - base::optional _file; + std::optional _file; Stats *_stats = nullptr; bool _inStats = false; diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index ebdfc686f..7cd6eb494 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -1058,7 +1058,7 @@ auto HtmlWriter::Wrap::pushMessage( } return "You have sent the following documents: " + SerializeList(list); - }, [](const base::none_type &) { return QByteArray(); }); + }, [](std::nullopt_t) { return QByteArray(); }); if (!serviceText.isEmpty()) { const auto &content = message.action.content; @@ -1658,7 +1658,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData( result.status = Data::FormatMoneyAmount(data.amount, data.currency); }, [](const UnsupportedMedia &data) { Unexpected("Unsupported message."); - }, [](const base::none_type &) {}); + }, [](std::nullopt_t) {}); return result; } @@ -2276,7 +2276,7 @@ Result HtmlWriter::writeDialogSlice(const Data::MessagesSlice &data) { ? ((_messagesCount - 1) / kMessagesInFile) : 0; auto previous = _lastMessageInfo.get(); - auto saved = base::optional(); + auto saved = std::optional(); auto block = QByteArray(); for (const auto &message : data.list) { const auto newIndex = (_messagesCount / kMessagesInFile); @@ -2291,7 +2291,7 @@ Result HtmlWriter::writeDialogSlice(const Data::MessagesSlice &data) { block = QByteArray(); _lastMessageInfo = nullptr; previous = nullptr; - saved = base::none; + saved = std::nullopt; oldIndex = newIndex; } else { return next; diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index e306db49b..02f70c901 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -458,7 +458,7 @@ QByteArray SerializeMessage( }())); } pushBare("values", SerializeArray(context, list)); - }, [](const base::none_type &) {}); + }, [](std::nullopt_t) {}); if (!message.action.content) { pushFrom(); @@ -572,7 +572,7 @@ QByteArray SerializeMessage( })); }, [](const UnsupportedMedia &data) { Unexpected("Unsupported message."); - }, [](const base::none_type &) {}); + }, [](std::nullopt_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 97f2a88c8..784c8a9d9 100644 --- a/Telegram/SourceFiles/export/output/export_output_text.cpp +++ b/Telegram/SourceFiles/export/output/export_output_text.cpp @@ -332,7 +332,7 @@ QByteArray SerializeMessage( } else if (!list.empty()) { push("Values", JoinList(", ", list)); } - }, [](const base::none_type &) {}); + }, [](std::nullopt_t) {}); if (!message.action.content) { pushFrom(); @@ -435,7 +435,7 @@ QByteArray SerializeMessage( })); }, [](const UnsupportedMedia &data) { Unexpected("Unsupported message."); - }, [](const base::none_type &) {}); + }, [](std::nullopt_t) {}); auto value = JoinList(QByteArray(), ranges::view::all( message.text diff --git a/Telegram/SourceFiles/history/feed/history_feed_section.cpp b/Telegram/SourceFiles/history/feed/history_feed_section.cpp index 98fa109c5..ee39ec781 100644 --- a/Telegram/SourceFiles/history/feed/history_feed_section.cpp +++ b/Telegram/SourceFiles/history/feed/history_feed_section.cpp @@ -199,7 +199,7 @@ void Widget::updateScrollDownVisibility() { return; } - const auto scrollDownIsVisible = [&]() -> base::optional { + const auto scrollDownIsVisible = [&]() -> std::optional { const auto top = _scroll->scrollTop() + st::historyToDownShownAfter; if (top < _scroll->scrollTopMax()) { return true; @@ -207,7 +207,7 @@ void Widget::updateScrollDownVisibility() { if (_inner->loadedAtBottomKnown()) { return !_inner->loadedAtBottom(); } - return base::none; + return std::nullopt; }; const auto scrollDownIsShown = scrollDownIsVisible(); if (!scrollDownIsShown) { @@ -368,11 +368,11 @@ void Widget::listVisibleItemsChanged(HistoryItemsList &&items) { } } -base::optional Widget::listUnreadBarView( +std::optional Widget::listUnreadBarView( const std::vector> &elements) { const auto position = _feed->unreadPosition(); if (!position || elements.empty() || !_feed->unreadCount()) { - return base::none; + return std::nullopt; } const auto minimal = ranges::upper_bound( elements, @@ -380,14 +380,14 @@ base::optional Widget::listUnreadBarView( std::less<>(), [](auto view) { return view->data()->position(); }); if (minimal == end(elements)) { - return base::none; + return std::nullopt; } const auto view = *minimal; const auto unreadMessagesHeight = elements.back()->y() + elements.back()->height() - view->y(); if (unreadMessagesHeight < _scroll->height()) { - return base::none; + return std::nullopt; } return base::make_optional(int(minimal - begin(elements))); } @@ -482,7 +482,7 @@ void Widget::updateControlsGeometry() { const auto contentWidth = width(); const auto newScrollTop = _scroll->isHidden() - ? base::none + ? std::nullopt : base::make_optional(_scroll->scrollTop() + topDelta()); _topBar->resizeToWidth(contentWidth); _topBarShadow->resize(contentWidth, st::lineWidth); diff --git a/Telegram/SourceFiles/history/feed/history_feed_section.h b/Telegram/SourceFiles/history/feed/history_feed_section.h index 75726b7e5..07077dd36 100644 --- a/Telegram/SourceFiles/history/feed/history_feed_section.h +++ b/Telegram/SourceFiles/history/feed/history_feed_section.h @@ -86,7 +86,7 @@ public: void listSelectionChanged( HistoryView::SelectedItems &&items) override; void listVisibleItemsChanged(HistoryItemsList &&items) override; - base::optional listUnreadBarView( + std::optional listUnreadBarView( const std::vector> &elements) override; void listContentRefreshed() override; ClickHandlerPtr listDateLink(not_null view) override; @@ -135,7 +135,7 @@ private: FullMsgId _currentMessageId; FullMsgId _highlightMessageId; - base::optional _nextAnimatedScrollPosition; + std::optional _nextAnimatedScrollPosition; int _nextAnimatedScrollDelta = 0; Animation _scrollDownShown; diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 8891ef251..6fb0744b5 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -294,7 +294,7 @@ void History::setHasPendingResizedItems() { void History::itemRemoved(not_null item) { item->removeMainView(); if (lastMessage() == item) { - _lastMessage = base::none; + _lastMessage = std::nullopt; if (loadedAtBottom()) { if (const auto last = lastAvailableMessage()) { setLastMessage(last); @@ -423,7 +423,7 @@ void History::setSentDraftText(const QString &text) { void History::clearSentDraftText(const QString &text) { if (_lastSentDraftText && *_lastSentDraftText == text) { - _lastSentDraftText = base::none; + _lastSentDraftText = std::nullopt; } accumulate_max(_lastSentDraftTime, unixtime()); } diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index 54556c337..e4822988f 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -491,12 +491,12 @@ private: bool _loadedAtTop = false; bool _loadedAtBottom = true; - base::optional _inboxReadBefore; - base::optional _outboxReadBefore; - base::optional _unreadCount; - base::optional _unreadMentionsCount; + std::optional _inboxReadBefore; + std::optional _outboxReadBefore; + std::optional _unreadCount; + std::optional _unreadMentionsCount; base::flat_set _unreadMentions; - base::optional _lastMessage; + std::optional _lastMessage; bool _unreadMark = false; // A pointer to the block that is currently being built. @@ -510,7 +510,7 @@ private: std::unique_ptr _localDraft, _cloudDraft; std::unique_ptr _editDraft; - base::optional _lastSentDraftText; + std::optional _lastSentDraftText; TimeId _lastSentDraftTime = 0; MessageIdsList _forwardDraft; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 23e610e26..9d456e965 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4584,7 +4584,7 @@ void HistoryWidget::documentUploaded( const FullMsgId &newId, bool silent, const MTPInputFile &file) { - Auth().api().sendUploadedDocument(newId, file, base::none, silent); + Auth().api().sendUploadedDocument(newId, file, std::nullopt, silent); } void HistoryWidget::thumbDocumentUploaded( @@ -5071,7 +5071,7 @@ bool HistoryWidget::hasPendingResizedItems() const { || (_migrated && _migrated->hasPendingResizedItems()); } -base::optional HistoryWidget::unreadBarTop() const { +std::optional HistoryWidget::unreadBarTop() const { auto getUnreadBar = [this]() -> HistoryView::Element* { if (const auto bar = _migrated ? _migrated->unreadBar() : nullptr) { return bar; @@ -5088,7 +5088,7 @@ base::optional HistoryWidget::unreadBarTop() const { } return result; } - return base::none; + return std::nullopt; } HistoryView::Element *HistoryWidget::firstUnreadMessage() const { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 8b8446b6f..e2a5cbd14 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -684,7 +684,7 @@ private: // Counts scrollTop for placing the scroll right at the unread // messages bar, choosing from _history and _migrated unreadBar. - base::optional unreadBarTop() const; + std::optional unreadBarTop() const; int itemTopForHighlight(not_null view) const; void scrollToCurrentVoiceMessage(FullMsgId fromId, FullMsgId toId); HistoryView::Element *firstUnreadMessage() const; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index c31a089fc..73a9d3c5c 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -328,24 +328,24 @@ void ListWidget::refreshRows() { _delegate->listContentRefreshed(); } -base::optional ListWidget::scrollTopForPosition( +std::optional ListWidget::scrollTopForPosition( Data::MessagePosition position) const { if (position == Data::MaxMessagePosition) { if (loadedAtBottom()) { return height(); } - return base::none; + return std::nullopt; } else if (_items.empty() || isBelowPosition(position) || isAbovePosition(position)) { - return base::none; + return std::nullopt; } const auto index = findNearestItem(position); const auto view = _items[index]; return scrollTopForView(_items[index]); } -base::optional ListWidget::scrollTopForView( +std::optional ListWidget::scrollTopForView( not_null view) const { if (view->isHiddenByGroup()) { if (const auto group = Auth().data().groups().find(view->data())) { diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index 41de57466..e2c835581 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -62,7 +62,7 @@ public: not_null second) = 0; virtual void listSelectionChanged(SelectedItems &&items) = 0; virtual void listVisibleItemsChanged(HistoryItemsList &&items) = 0; - virtual base::optional listUnreadBarView( + virtual std::optional listUnreadBarView( const std::vector> &elements) = 0; virtual void listContentRefreshed() = 0; virtual ClickHandlerPtr listDateLink(not_null view) = 0; @@ -136,9 +136,9 @@ public: void saveState(not_null memento); void restoreState(not_null memento); - base::optional scrollTopForPosition( + std::optional scrollTopForPosition( Data::MessagePosition position) const; - base::optional scrollTopForView(not_null view) const; + std::optional scrollTopForView(not_null view) const; enum class AnimatedScroll { Full, Part, diff --git a/Telegram/SourceFiles/info/feed/info_feed_channels.h b/Telegram/SourceFiles/info/feed/info_feed_channels.h index fd1446217..585204237 100644 --- a/Telegram/SourceFiles/info/feed/info_feed_channels.h +++ b/Telegram/SourceFiles/info/feed/info_feed_channels.h @@ -33,7 +33,7 @@ namespace FeedProfile { class Memento; struct ChannelsState { std::unique_ptr list; - base::optional search; + std::optional search; }; class Channels diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index 6cbdb5399..37c5f8e4b 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -981,7 +981,7 @@ auto ListWidget::findItemByPoint(QPoint point) const -> FoundItem { } auto ListWidget::findItemById( - UniversalMsgId universalId) -> base::optional { + UniversalMsgId universalId) -> std::optional { auto sectionIt = findSectionByItem(universalId); if (sectionIt != _sections.end()) { auto item = sectionIt->findItemNearId(universalId); @@ -989,14 +989,14 @@ auto ListWidget::findItemById( return foundItemInSection(item, *sectionIt); } } - return base::none; + return std::nullopt; } auto ListWidget::findItemDetails( - BaseLayout *item) -> base::optional { + BaseLayout *item) -> std::optional { return item ? findItemById(GetUniversalId(item)) - : base::none; + : std::nullopt; } auto ListWidget::foundItemInSection( @@ -1058,7 +1058,7 @@ void ListWidget::checkMoveToOtherViewer() { auto delta = _slice.distance( sliceKey(_universalAroundId), sliceKey(universalId)); - Assert(delta != base::none); + Assert(delta != std::nullopt); preloadRequired = (qAbs(*delta) >= minUniversalIdDelta); } if (preloadRequired) { diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.h b/Telegram/SourceFiles/info/media/info_media_list_widget.h index 249258494..598f1fa25 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.h @@ -230,8 +230,8 @@ private: std::vector
::const_iterator from, int bottom) const; FoundItem findItemByPoint(QPoint point) const; - base::optional findItemById(UniversalMsgId universalId); - base::optional findItemDetails(BaseLayout *item); + std::optional findItemById(UniversalMsgId universalId); + std::optional findItemDetails(BaseLayout *item); FoundItem foundItemInSection( const FoundItem &item, const Section §ion) const; diff --git a/Telegram/SourceFiles/info/media/info_media_widget.cpp b/Telegram/SourceFiles/info/media/info_media_widget.cpp index bcfb88399..dad143584 100644 --- a/Telegram/SourceFiles/info/media/info_media_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_widget.cpp @@ -16,13 +16,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Info { namespace Media { -base::optional TypeToTabIndex(Type type) { +std::optional TypeToTabIndex(Type type) { switch (type) { case Type::Photo: return 0; case Type::Video: return 1; case Type::File: return 2; } - return base::none; + return std::nullopt; } Type TabIndexToType(int index) { diff --git a/Telegram/SourceFiles/info/media/info_media_widget.h b/Telegram/SourceFiles/info/media/info_media_widget.h index ba47a0de1..a64f6c9cf 100644 --- a/Telegram/SourceFiles/info/media/info_media_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_widget.h @@ -17,7 +17,7 @@ namespace Media { using Type = Storage::SharedMediaType; -base::optional TypeToTabIndex(Type type); +std::optional TypeToTabIndex(Type type); Type TabIndexToType(int index); class InnerWidget; diff --git a/Telegram/SourceFiles/info/profile/info_profile_button.cpp b/Telegram/SourceFiles/info/profile/info_profile_button.cpp index 89f87b6a6..e1b10caf0 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_button.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_button.cpp @@ -62,7 +62,7 @@ bool Button::toggled() const { return _toggle ? _toggle->checked() : false; } -void Button::setColorOverride(base::optional textColorOverride) { +void Button::setColorOverride(std::optional textColorOverride) { _textColorOverride = textColorOverride; update(); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_button.h b/Telegram/SourceFiles/info/profile/info_profile_button.h index ebcfbc496..ee7239a67 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_button.h +++ b/Telegram/SourceFiles/info/profile/info_profile_button.h @@ -30,7 +30,7 @@ public: rpl::producer toggledValue() const; bool toggled() const; - void setColorOverride(base::optional textColorOverride); + void setColorOverride(std::optional textColorOverride); protected: int resizeGetHeight(int newWidth) override; @@ -51,7 +51,7 @@ private: int _originalWidth = 0; int _textWidth = 0; std::unique_ptr _toggle; - base::optional _textColorOverride; + std::optional _textColorOverride; }; diff --git a/Telegram/SourceFiles/info/profile/info_profile_members.h b/Telegram/SourceFiles/info/profile/info_profile_members.h index 5fcf81b72..2be980c70 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members.h +++ b/Telegram/SourceFiles/info/profile/info_profile_members.h @@ -34,7 +34,7 @@ class Button; class Memento; struct MembersState { std::unique_ptr list; - base::optional search; + std::optional search; }; class Members diff --git a/Telegram/SourceFiles/media/player/media_player_instance.cpp b/Telegram/SourceFiles/media/player/media_player_instance.cpp index 9712ecf13..2d3a12a0a 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.cpp +++ b/Telegram/SourceFiles/media/player/media_player_instance.cpp @@ -127,7 +127,7 @@ void Instance::playlistUpdated(not_null data) { const auto fullId = data->current.contextId(); data->playlistIndex = data->playlistSlice->indexOf(fullId); } else { - data->playlistIndex = base::none; + data->playlistIndex = std::nullopt; } data->playlistChanges.fire({}); } @@ -146,7 +146,7 @@ bool Instance::validPlaylist(not_null data) { return [&](const SparseIdsMergedSlice &data) { return inSameDomain(a, b) ? data.distance(a, b) - : base::optional(); + : std::optional(); }; }; @@ -180,14 +180,14 @@ void Instance::validatePlaylist(not_null data) { playlistUpdated(data); }, data->playlistLifetime); } else { - data->playlistSlice = base::none; - data->playlistSliceKey = data->playlistRequestedKey = base::none; + data->playlistSlice = std::nullopt; + data->playlistSliceKey = data->playlistRequestedKey = std::nullopt; playlistUpdated(data); } } auto Instance::playlistKey(not_null data) const --> base::optional { +-> std::optional { const auto contextId = data->current.contextId(); const auto history = data->history; if (!contextId || !history || !IsServerMsgId(contextId.msg)) { diff --git a/Telegram/SourceFiles/media/player/media_player_instance.h b/Telegram/SourceFiles/media/player/media_player_instance.h index a301e1f53..e82e5ecfe 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.h +++ b/Telegram/SourceFiles/media/player/media_player_instance.h @@ -139,10 +139,10 @@ private: Storage::SharedMediaType overview; AudioMsgId current; AudioMsgId seeking; - base::optional playlistSlice; - base::optional playlistSliceKey; - base::optional playlistRequestedKey; - base::optional playlistIndex; + std::optional playlistSlice; + std::optional playlistSliceKey; + std::optional playlistRequestedKey; + std::optional playlistIndex; rpl::lifetime playlistLifetime; rpl::event_stream<> playlistChanges; History *history = nullptr; @@ -156,7 +156,7 @@ private: void setCurrent(const AudioMsgId &audioId); void refreshPlaylist(not_null data); - base::optional playlistKey(not_null data) const; + std::optional playlistKey(not_null data) const; bool validPlaylist(not_null data); void validatePlaylist(not_null data); void playlistUpdated(not_null data); diff --git a/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp b/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp index d3f436f83..5ed4f0842 100644 --- a/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp +++ b/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp @@ -53,7 +53,7 @@ Context ComputeContext(const SharedMediaWithLastSlice &slice, int index) { if (const auto peer = (*photo)->peer) { return peer->id; } - return base::none; + return std::nullopt; } else if (const auto msgId = base::get_if(&value)) { if (const auto item = App::histItemById(*msgId)) { if (!item->toHistoryMessage()) { @@ -62,7 +62,7 @@ Context ComputeContext(const SharedMediaWithLastSlice &slice, int index) { return groupId; } } - return base::none; + return std::nullopt; } Unexpected("Variant in ComputeContext(SharedMediaWithLastSlice::Value)"); } diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 398060357..a064d67f4 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -464,7 +464,7 @@ void MediaView::updateActions() { } auto MediaView::computeOverviewType() const --> base::optional { +-> std::optional { if (const auto mediaType = sharedMediaType()) { if (const auto overviewType = SharedMediaOverviewType(*mediaType)) { return overviewType; @@ -476,7 +476,7 @@ auto MediaView::computeOverviewType() const } } } - return base::none; + return std::nullopt; } void MediaView::step_state(TimeMs ms, bool timer) { @@ -697,7 +697,7 @@ void MediaView::clearData() { stopGif(); delete _menu; _menu = nullptr; - setContext(base::none); + setContext(std::nullopt); _from = nullptr; _photo = nullptr; _doc = nullptr; @@ -1082,7 +1082,7 @@ void MediaView::onCopy() { } } -base::optional MediaView::sharedMediaType() const { +std::optional MediaView::sharedMediaType() const { using Type = SharedMediaType; if (auto item = App::histItemById(_msgid)) { if (_photo) { @@ -1099,10 +1099,10 @@ base::optional MediaView::sharedMediaType() const { return Type::File; } } - return base::none; + return std::nullopt; } -base::optional MediaView::sharedMediaKey() const { +std::optional MediaView::sharedMediaKey() const { if (!_msgid && _peer && !_user && _photo && _peer->userpicPhotoId() == _photo->id) { return SharedMediaKey { _history->peer->id, @@ -1112,7 +1112,7 @@ base::optional MediaView::sharedMediaKey() const { }; } if (!IsServerMsgId(_msgid.msg)) { - return base::none; + return std::nullopt; } auto keyForType = [this](SharedMediaType type) -> SharedMediaKey { return { @@ -1152,7 +1152,7 @@ bool MediaView::validSharedMedia() const { return [&](const SharedMediaWithLastSlice &data) { return inSameDomain(a, b) ? data.distance(a, b) - : base::optional(); + : std::optional(); }; }; @@ -1188,15 +1188,15 @@ void MediaView::validateSharedMedia() { }, _sharedMedia->lifetime); } else { _sharedMedia = nullptr; - _sharedMediaData = base::none; - _sharedMediaDataKey = base::none; + _sharedMediaData = std::nullopt; + _sharedMediaDataKey = std::nullopt; } } void MediaView::handleSharedMediaUpdate(SharedMediaWithLastSlice &&update) { if ((!_photo && !_doc) || !_sharedMedia) { - _sharedMediaData = base::none; - _sharedMediaDataKey = base::none; + _sharedMediaData = std::nullopt; + _sharedMediaDataKey = std::nullopt; } else { _sharedMediaData = std::move(update); _sharedMediaDataKey = _sharedMedia->key; @@ -1206,14 +1206,14 @@ void MediaView::handleSharedMediaUpdate(SharedMediaWithLastSlice &&update) { preloadData(0); } -base::optional MediaView::userPhotosKey() const { +std::optional MediaView::userPhotosKey() const { if (!_msgid && _user && _photo) { return UserPhotosKey { _user->bareId(), _photo->id }; } - return base::none; + return std::nullopt; } bool MediaView::validUserPhotos() const { @@ -1251,13 +1251,13 @@ void MediaView::validateUserPhotos() { }, _userPhotos->lifetime); } else { _userPhotos = nullptr; - _userPhotosData = base::none; + _userPhotosData = std::nullopt; } } void MediaView::handleUserPhotosUpdate(UserPhotosSlice &&update) { if (!_photo || !_userPhotos) { - _userPhotosData = base::none; + _userPhotosData = std::nullopt; } else { _userPhotosData = std::move(update); } @@ -1358,7 +1358,7 @@ void MediaView::showPhoto(not_null photo, HistoryItem *context) { if (context) { setContext(context); } else { - setContext(base::none); + setContext(std::nullopt); } _firstOpenedPeerPhoto = false; @@ -1410,7 +1410,7 @@ void MediaView::showDocument(not_null document, HistoryItem *cont if (context) { setContext(context); } else { - setContext(base::none); + setContext(std::nullopt); } _photo = nullptr; @@ -2467,19 +2467,19 @@ MediaView::Entity MediaView::entityForUserPhotos(int index) const { Expects(!!_userPhotosData); if (index < 0 || index >= _userPhotosData->size()) { - return { base::none, nullptr }; + return { std::nullopt, nullptr }; } if (auto photo = Auth().data().photo((*_userPhotosData)[index])) { return { photo, nullptr }; } - return { base::none, nullptr }; + return { std::nullopt, nullptr }; } MediaView::Entity MediaView::entityForSharedMedia(int index) const { Expects(!!_sharedMediaData); if (index < 0 || index >= _sharedMediaData->size()) { - return { base::none, nullptr }; + return { std::nullopt, nullptr }; } auto value = (*_sharedMediaData)[index]; if (const auto photo = base::get_if>(&value)) { @@ -2488,7 +2488,7 @@ MediaView::Entity MediaView::entityForSharedMedia(int index) const { } else if (const auto itemId = base::get_if(&value)) { return entityForItemId(*itemId); } - return { base::none, nullptr }; + return { std::nullopt, nullptr }; } MediaView::Entity MediaView::entityForItemId(const FullMsgId &itemId) const { @@ -2500,9 +2500,9 @@ MediaView::Entity MediaView::entityForItemId(const FullMsgId &itemId) const { return { document, item }; } } - return { base::none, item }; + return { std::nullopt, item }; } - return { base::none, nullptr }; + return { std::nullopt, nullptr }; } MediaView::Entity MediaView::entityByIndex(int index) const { @@ -2511,7 +2511,7 @@ MediaView::Entity MediaView::entityByIndex(int index) const { } else if (_userPhotosData) { return entityForUserPhotos(index); } - return { base::none, nullptr }; + return { std::nullopt, nullptr }; } void MediaView::setContext(base::optional_variant< @@ -2563,7 +2563,7 @@ bool MediaView::moveToEntity(const Entity &entity, int preloadDelta) { } else if (_peer) { setContext(_peer); } else { - setContext(base::none); + setContext(std::nullopt); } stopGif(); if (auto photo = base::get_if>(&entity.data)) { @@ -3004,10 +3004,10 @@ bool MediaView::eventFilter(QObject *obj, QEvent *e) { void MediaView::setVisible(bool visible) { if (!visible) { _sharedMedia = nullptr; - _sharedMediaData = base::none; - _sharedMediaDataKey = base::none; + _sharedMediaData = std::nullopt; + _sharedMediaDataKey = std::nullopt; _userPhotos = nullptr; - _userPhotosData = base::none; + _userPhotosData = std::nullopt; if (_menu) _menu->hideMenu(true); _controlsHideTimer.stop(); _controlsState = ControlsShown; @@ -3064,19 +3064,19 @@ void MediaView::findCurrent() { if (_sharedMediaData) { _index = _msgid ? _sharedMediaData->indexOf(_msgid) - : _photo ? _sharedMediaData->indexOf(_photo) : base::none; + : _photo ? _sharedMediaData->indexOf(_photo) : std::nullopt; _fullIndex = _sharedMediaData->skippedBefore() ? (_index | func::add(*_sharedMediaData->skippedBefore())) - : base::none; + : std::nullopt; _fullCount = _sharedMediaData->fullCount(); } else if (_userPhotosData) { - _index = _photo ? _userPhotosData->indexOf(_photo->id) : base::none; + _index = _photo ? _userPhotosData->indexOf(_photo->id) : std::nullopt; _fullIndex = _userPhotosData->skippedBefore() ? (_index | func::add(*_userPhotosData->skippedBefore())) - : base::none; + : std::nullopt; _fullCount = _userPhotosData->fullCount(); } else { - _index = _fullIndex = _fullCount = base::none; + _index = _fullIndex = _fullCount = std::nullopt; } } @@ -3105,7 +3105,7 @@ void MediaView::updateHeader() { _headerText = lang(lng_mediaview_single_photo); } } - _headerHasLink = computeOverviewType() != base::none; + _headerHasLink = computeOverviewType() != std::nullopt; auto hwidth = st::mediaviewThickFont->width(_headerText); if (hwidth > width() / 3) { hwidth = width() / 3; diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index 502cce114..266e91716 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -161,16 +161,16 @@ private: struct SharedMedia; using SharedMediaType = SharedMediaWithLastSlice::Type; using SharedMediaKey = SharedMediaWithLastSlice::Key; - base::optional sharedMediaType() const; - base::optional sharedMediaKey() const; - base::optional computeOverviewType() const; + std::optional sharedMediaType() const; + std::optional sharedMediaKey() const; + std::optional computeOverviewType() const; bool validSharedMedia() const; void validateSharedMedia(); void handleSharedMediaUpdate(SharedMediaWithLastSlice &&update); struct UserPhotos; using UserPhotosKey = UserPhotosSlice::Key; - base::optional userPhotosKey() const; + std::optional userPhotosKey() const; bool validUserPhotos() const; void validateUserPhotos(); void handleUserPhotosUpdate(UserPhotosSlice &&update); @@ -249,10 +249,10 @@ private: PhotoData *_photo = nullptr; DocumentData *_doc = nullptr; std::unique_ptr _sharedMedia; - base::optional _sharedMediaData; - base::optional _sharedMediaDataKey; + std::optional _sharedMediaData; + std::optional _sharedMediaDataKey; std::unique_ptr _userPhotos; - base::optional _userPhotosData; + std::optional _userPhotosData; QRect _closeNav, _closeNavIcon; QRect _leftNav, _leftNavIcon, _rightNav, _rightNavIcon; @@ -332,9 +332,9 @@ private: PeerData *_from = nullptr; Text _fromName; - base::optional _index; // Index in current _sharedMedia data. - base::optional _fullIndex; // Index in full shared media. - base::optional _fullCount; + std::optional _index; // Index in current _sharedMedia data. + std::optional _fullIndex; // Index in full shared media. + std::optional _fullCount; FullMsgId _msgid; bool _canForwardItem = false; bool _canDeleteItem = false; diff --git a/Telegram/SourceFiles/messenger.cpp b/Telegram/SourceFiles/messenger.cpp index f4f3bb44f..846d752d2 100644 --- a/Telegram/SourceFiles/messenger.cpp +++ b/Telegram/SourceFiles/messenger.cpp @@ -969,8 +969,8 @@ void Messenger::unlockTerms() { } } -base::optional Messenger::termsLocked() const { - return _termsLock ? base::make_optional(*_termsLock) : base::none; +std::optional Messenger::termsLocked() const { + return _termsLock ? base::make_optional(*_termsLock) : std::nullopt; } rpl::producer Messenger::termsLockChanges() const { diff --git a/Telegram/SourceFiles/messenger.h b/Telegram/SourceFiles/messenger.h index 73195bbb7..b6e13cc4d 100644 --- a/Telegram/SourceFiles/messenger.h +++ b/Telegram/SourceFiles/messenger.h @@ -177,7 +177,7 @@ public: void lockByTerms(const Window::TermsLock &data); void unlockTerms(); - [[nodiscard]] base::optional termsLocked() const; + [[nodiscard]] std::optional termsLocked() const; rpl::producer termsLockChanges() const; rpl::producer termsLockValue() const; void termsDeleteNow(); diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index 23b233cea..119abbff7 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -151,9 +151,9 @@ private: void configLoadDone(const MTPConfig &result); bool configLoadFail(const RPCError &error); - base::optional queryRequestByDc( + std::optional queryRequestByDc( mtpRequestId requestId) const; - base::optional changeRequestByDc( + std::optional changeRequestByDc( mtpRequestId requestId, DcId newdc); // RPCError::NoError means do not toggle onError callback. @@ -806,17 +806,17 @@ bool Instance::Private::configLoadFail(const RPCError &error) { return false; } -base::optional Instance::Private::queryRequestByDc( +std::optional Instance::Private::queryRequestByDc( mtpRequestId requestId) const { QMutexLocker locker(&_requestByDcLock); auto it = _requestsByDc.find(requestId); if (it != _requestsByDc.cend()) { return it->second; } - return base::none; + return std::nullopt; } -base::optional Instance::Private::changeRequestByDc( +std::optional Instance::Private::changeRequestByDc( mtpRequestId requestId, DcId newdc) { QMutexLocker locker(&_requestByDcLock); @@ -829,7 +829,7 @@ base::optional Instance::Private::changeRequestByDc( } return it->second; } - return base::none; + return std::nullopt; } void Instance::Private::checkDelayedRequests() { diff --git a/Telegram/SourceFiles/passport/passport_encryption.h b/Telegram/SourceFiles/passport/passport_encryption.h index 2c5e653fe..69e0a62fd 100644 --- a/Telegram/SourceFiles/passport/passport_encryption.h +++ b/Telegram/SourceFiles/passport/passport_encryption.h @@ -24,7 +24,7 @@ std::map DeserializeData(bytes::const_span bytes); struct DataError { // QByteArray - bad existing scan with such file_hash // QString - bad data field value with such key - // base::none - additional scan required + // std::nullopt - additional scan required base::optional_variant key; QString type; // personal_details, passport, etc. QString text; diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 2546b9da3..0d5140b9b 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -559,7 +559,7 @@ const std::vector &Value::filesInEdit(FileType type) const { Unexpected("Type in Value::filesInEdit() const."); } -EditFile &Value::fileInEdit(FileType type, base::optional fileIndex) { +EditFile &Value::fileInEdit(FileType type, std::optional fileIndex) { switch (type) { case FileType::Scan: case FileType::Translation: { @@ -577,7 +577,7 @@ EditFile &Value::fileInEdit(FileType type, base::optional fileIndex) { const EditFile &Value::fileInEdit( FileType type, - base::optional fileIndex) const { + std::optional fileIndex) const { switch (type) { case FileType::Scan: case FileType::Translation: { @@ -1232,7 +1232,7 @@ void FormController::fillNativeFromFallback() { // Check if additional values should be copied from fallback values. const auto scheme = GetDocumentScheme( Scope::Type::PersonalDetails, - base::none, + std::nullopt, true); const auto dependencyIt = values.fields.find( scheme.additionalDependencyKey); @@ -1363,7 +1363,7 @@ void FormController::uploadScan( return; } const auto nonconst = findValue(value); - const auto fileIndex = [&]() -> base::optional { + const auto fileIndex = [&]() -> std::optional { auto scanInEdit = EditFile{ nonconst, type, File(), nullptr }; if (type == FileType::Scan || type == FileType::Translation) { auto &list = nonconst->filesInEdit(type); @@ -1379,7 +1379,7 @@ void FormController::uploadScan( type, std::move(scanInEdit)).first; } - return base::none; + return std::nullopt; }(); auto &scan = nonconst->fileInEdit(type, fileIndex); encryptFile(scan, std::move(content), [=](UploadScanData &&result) { @@ -1392,14 +1392,14 @@ void FormController::uploadScan( void FormController::deleteScan( not_null value, FileType type, - base::optional fileIndex) { + std::optional fileIndex) { scanDeleteRestore(value, type, fileIndex, true); } void FormController::restoreScan( not_null value, FileType type, - base::optional fileIndex) { + std::optional fileIndex) { scanDeleteRestore(value, type, fileIndex, false); } @@ -1454,7 +1454,7 @@ void FormController::encryptFile( void FormController::scanDeleteRestore( not_null value, FileType type, - base::optional fileIndex, + std::optional fileIndex, bool deleted) { const auto nonconst = findValue(value); auto &scan = nonconst->fileInEdit(type, fileIndex); @@ -1723,7 +1723,7 @@ void FormController::loadFile(File &file) { file.id, file.accessHash, QByteArray(), // file_reference - base::none, // origin + std::nullopt, // origin SecureFileLocation, QString(), file.size, @@ -2299,10 +2299,10 @@ auto FormController::parseFiles( auto FormController::parseFile( const MTPSecureFile &data, const std::vector &editData) const --> base::optional { +-> std::optional { switch (data.type()) { case mtpc_secureFileEmpty: - return base::none; + return std::nullopt; case mtpc_secureFile: { const auto &fields = data.c_secureFile(); diff --git a/Telegram/SourceFiles/passport/passport_form_controller.h b/Telegram/SourceFiles/passport/passport_form_controller.h index d22cda41c..53cf8bca3 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.h +++ b/Telegram/SourceFiles/passport/passport_form_controller.h @@ -205,10 +205,10 @@ struct Value { const QString &fileMissingError(FileType type) const; std::vector &filesInEdit(FileType type); const std::vector &filesInEdit(FileType type) const; - EditFile &fileInEdit(FileType type, base::optional fileIndex); + EditFile &fileInEdit(FileType type, std::optional fileIndex); const EditFile &fileInEdit( FileType type, - base::optional fileIndex) const; + std::optional fileIndex) const; std::vector takeAllFilesInEdit(); @@ -345,11 +345,11 @@ public: void deleteScan( not_null value, FileType type, - base::optional fileIndex); + std::optional fileIndex); void restoreScan( not_null value, FileType type, - base::optional fileIndex); + std::optional fileIndex); rpl::producer<> secretReadyEvents() const; @@ -407,7 +407,7 @@ private: std::vector parseFiles( const QVector &data, const std::vector &editData) const; - base::optional parseFile( + std::optional parseFile( const MTPSecureFile &data, const std::vector &editData) const; void fillDownloadedFile( @@ -474,7 +474,7 @@ private: void scanDeleteRestore( not_null value, FileType type, - base::optional fileIndex, + std::optional fileIndex, bool deleted); QString getPhoneFromValue(not_null value) const; diff --git a/Telegram/SourceFiles/passport/passport_form_view_controller.cpp b/Telegram/SourceFiles/passport/passport_form_view_controller.cpp index 94f292797..3cff0e2e0 100644 --- a/Telegram/SourceFiles/passport/passport_form_view_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_view_controller.cpp @@ -376,7 +376,7 @@ QString ComputeScopeRowReadyString(const Scope &scope) { } const auto scheme = GetDocumentScheme( scope.type, - document ? base::make_optional(document->type) : base::none, + document ? base::make_optional(document->type) : std::nullopt, scope.details ? scope.details->nativeNames : false); using ValueClass = EditDocumentScheme::ValueClass; const auto skipAdditional = [&] { diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index 9daaa5c7b..5518ddb62 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -106,7 +106,7 @@ std::map PrepareSpecialFiles(const Value &value) { EditDocumentScheme GetDocumentScheme( Scope::Type type, - base::optional scansType, + std::optional scansType, bool nativeNames) { using Scheme = EditDocumentScheme; using ValueClass = Scheme::ValueClass; @@ -127,7 +127,7 @@ EditDocumentScheme GetDocumentScheme( const auto FromBoolean = [](auto validation) { return [=](const QString &value) { return validation(value) - ? base::none + ? std::nullopt : base::make_optional(QString()); }; }; @@ -136,7 +136,7 @@ EditDocumentScheme GetDocumentScheme( return (value.size() >= min) && (value.size() <= max); }); }; - using Result = base::optional; + using Result = std::optional; const auto NameValidate = [](const QString &value) -> Result { if (value.isEmpty() || value.size() > kMaxNameSize) { return QString(); @@ -145,7 +145,7 @@ EditDocumentScheme GetDocumentScheme( ).match(value).hasMatch()) { return lang(lng_passport_bad_name); } - return base::none; + return std::nullopt; }; const auto NativeNameValidate = LimitedValidate(kMaxNameSize); const auto NativeNameOrEmptyValidate = LimitedValidate(kMaxNameSize, 0); @@ -174,7 +174,7 @@ EditDocumentScheme GetDocumentScheme( }); const auto NameOrEmptyValidate = [=](const QString &value) -> Result { if (value.isEmpty()) { - return base::none; + return std::nullopt; } return NameValidate(value); }; @@ -765,7 +765,7 @@ void PanelController::uploadScan(FileType type, QByteArray &&content) { void PanelController::deleteScan( FileType type, - base::optional fileIndex) { + std::optional fileIndex) { Expects(_editScope != nullptr); Expects(_editDocument != nullptr); Expects(_editDocument->requiresScan(type)); @@ -775,7 +775,7 @@ void PanelController::deleteScan( void PanelController::restoreScan( FileType type, - base::optional fileIndex) { + std::optional fileIndex) { Expects(_editScope != nullptr); Expects(_editDocument != nullptr); Expects(_editDocument->requiresScan(type)); @@ -808,13 +808,13 @@ std::vector PanelController::collectSaveErrors( } auto PanelController::deleteValueLabel() const --> base::optional> { +-> std::optional> { Expects(_editScope != nullptr); if (hasValueDocument()) { return Lang::Viewer(lng_passport_delete_document); } else if (!hasValueFields()) { - return base::none; + return std::nullopt; } switch (_editScope->type) { case Scope::Type::PersonalDetails: @@ -969,7 +969,7 @@ void PanelController::ensurePanelCreated() { } } -base::optional PanelController::findBestDocumentIndex( +std::optional PanelController::findBestDocumentIndex( const Scope &scope) const { Expects(!scope.documents.empty()); @@ -981,7 +981,7 @@ base::optional PanelController::findBestDocumentIndex( return document->whatNotFilled(); }); return ((*i)->whatNotFilled() == Value::kNothingFilled) - ? base::none + ? std::nullopt : base::make_optional(int(i - begin(documents))); return -1; } @@ -992,7 +992,7 @@ void PanelController::editScope(int index) { const auto &scope = _scopes[index]; if (scope.documents.empty()) { - editScope(index, base::none); + editScope(index, std::nullopt); } else { const auto documentIndex = findBestDocumentIndex(scope); if (documentIndex || scope.documents.size() == 1) { @@ -1106,7 +1106,7 @@ void PanelController::readScanError(ReadScanError error) { bool PanelController::editRequiresScanUpload( int index, - base::optional documentIndex) const { + std::optional documentIndex) const { Expects(index >= 0 && index < _scopes.size()); Expects(!documentIndex || (*documentIndex >= 0 @@ -1125,7 +1125,7 @@ bool PanelController::editRequiresScanUpload( void PanelController::editScope( int index, - base::optional documentIndex) { + std::optional documentIndex) { if (editRequiresScanUpload(index, documentIndex)) { editWithUpload(index, *documentIndex); } else { @@ -1135,7 +1135,7 @@ void PanelController::editScope( void PanelController::startScopeEdit( int index, - base::optional documentIndex) { + std::optional documentIndex) { Expects(_panel != nullptr); Expects(index >= 0 && index < _scopes.size()); Expects(_scopes[index].details != 0 || documentIndex.has_value()); @@ -1168,7 +1168,7 @@ void PanelController::startScopeEdit( ? base::make_optional(PrepareScanListData( *_editDocument, FileType::Translation)) - : base::none; + : std::nullopt; auto result = _editValue ? object_ptr( _panel->widget(), @@ -1210,7 +1210,7 @@ void PanelController::startScopeEdit( this, GetDocumentScheme( _editScope->type, - base::none, + std::nullopt, _editValue->nativeNames), _editValue->error, _editValue->data.parsedInEdit); diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.h b/Telegram/SourceFiles/passport/passport_panel_controller.h index 78c39e27e..92e7a6c9f 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.h +++ b/Telegram/SourceFiles/passport/passport_panel_controller.h @@ -22,7 +22,7 @@ enum class ReadScanError; EditDocumentScheme GetDocumentScheme( Scope::Type type, - base::optional scansType, + std::optional scansType, bool nativeNames); EditContactScheme GetContactScheme(Scope::Type type); @@ -98,13 +98,13 @@ public: bool canAddScan(FileType type) const; void uploadScan(FileType type, QByteArray &&content); - void deleteScan(FileType type, base::optional fileIndex); - void restoreScan(FileType type, base::optional fileIndex); + void deleteScan(FileType type, std::optional fileIndex); + void restoreScan(FileType type, std::optional fileIndex); rpl::producer scanUpdated() const; rpl::producer saveErrors() const; void readScanError(ReadScanError error); - base::optional> deleteValueLabel() const; + std::optional> deleteValueLabel() const; void deleteValue(); QString defaultEmail() const; @@ -149,13 +149,13 @@ public: private: void ensurePanelCreated(); - void editScope(int index, base::optional documentIndex); + void editScope(int index, std::optional documentIndex); void editWithUpload(int index, int documentIndex); bool editRequiresScanUpload( int index, - base::optional documentIndex) const; - void startScopeEdit(int index, base::optional documentIndex); - base::optional findBestDocumentIndex(const Scope &scope) const; + std::optional documentIndex) const; + void startScopeEdit(int index, std::optional documentIndex); + std::optional findBestDocumentIndex(const Scope &scope) const; void requestScopeFilesType(int index); void cancelValueEdit(); void processValueSaveFinished(not_null value); diff --git a/Telegram/SourceFiles/passport/passport_panel_details_row.cpp b/Telegram/SourceFiles/passport/passport_panel_details_row.cpp index cbfaeb15f..e10551810 100644 --- a/Telegram/SourceFiles/passport/passport_panel_details_row.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_details_row.cpp @@ -225,7 +225,7 @@ private: Female, }; - static base::optional StringToGender(const QString &value); + static std::optional StringToGender(const QString &value); static QString GenderToString(Gender gender); int resizeInner(int left, int top, int width) override; @@ -366,7 +366,7 @@ void CountryRow::toggleError(bool shown) { void CountryRow::errorAnimationCallback() { const auto error = _errorAnimation.current(_errorShown ? 1. : 0.); if (error == 0.) { - _link->setColorOverride(base::none); + _link->setColorOverride(std::nullopt); } else { _link->setColorOverride(anim::color( st::boxLinkButton.color, @@ -877,13 +877,13 @@ std::unique_ptr GenderRow::createRadioView( } auto GenderRow::StringToGender(const QString &value) --> base::optional { +-> std::optional { if (value == qstr("male")) { return Gender::Male; } else if (value == qstr("female")) { return Gender::Female; } - return base::none; + return std::nullopt; } QString GenderRow::GenderToString(Gender gender) { @@ -936,8 +936,8 @@ void GenderRow::toggleError(bool shown) { void GenderRow::errorAnimationCallback() { const auto error = _errorAnimation.current(_errorShown ? 1. : 0.); if (error == 0.) { - _maleRadio->setUntoggledOverride(base::none); - _femaleRadio->setUntoggledOverride(base::none); + _maleRadio->setUntoggledOverride(std::nullopt); + _femaleRadio->setUntoggledOverride(std::nullopt); } else { const auto color = anim::color( st::defaultRadio.untoggledFg, @@ -1041,7 +1041,7 @@ int PanelDetailsRow::resizeGetHeight(int newWidth) { return result; } -void PanelDetailsRow::showError(base::optional error) { +void PanelDetailsRow::showError(std::optional error) { if (!_errorHideSubscription) { _errorHideSubscription = true; diff --git a/Telegram/SourceFiles/passport/passport_panel_details_row.h b/Telegram/SourceFiles/passport/passport_panel_details_row.h index d1ecd8bd2..73ed0cfbb 100644 --- a/Telegram/SourceFiles/passport/passport_panel_details_row.h +++ b/Telegram/SourceFiles/passport/passport_panel_details_row.h @@ -54,7 +54,7 @@ public: virtual bool setFocusFast(); virtual rpl::producer value() const = 0; virtual QString valueCurrent() const = 0; - void showError(base::optional error = base::none); + void showError(std::optional error = std::nullopt); bool errorShown() const; void hideError(); void finishAnimating(); diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp index d560a933c..bf8d29fa6 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp @@ -215,7 +215,7 @@ PanelEditDocument::PanelEditDocument( const QString &scansError, const ValueMap &scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles) : _controller(controller) , _scheme(std::move(scheme)) @@ -243,7 +243,7 @@ PanelEditDocument::PanelEditDocument( const QString &scansError, const ValueMap &scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles) : _controller(controller) , _scheme(std::move(scheme)) @@ -288,7 +288,7 @@ void PanelEditDocument::setupControls( const QString *scansError, const ValueMap *scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles) { const auto inner = setupContent( error, @@ -316,7 +316,7 @@ not_null PanelEditDocument::setupContent( const QString *scansError, const ValueMap *scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles) { const auto inner = _scroll->setOwnedWidget( object_ptr(this)); @@ -629,7 +629,7 @@ void PanelEditDocument::fillAdditionalFromFallbacks(Result &result) const { bool PanelEditDocument::validate() { auto error = _editScans ? _editScans->validateGetErrorTop() - : base::none; + : std::nullopt; if (error) { const auto errortop = _editScans->mapToGlobal(QPoint(0, *error)); const auto scrolltop = _scroll->mapToGlobal(QPoint(0, 0)); diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.h b/Telegram/SourceFiles/passport/passport_panel_edit_document.h index bb37adc14..c456084d2 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.h +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.h @@ -50,7 +50,7 @@ struct EditDocumentScheme { Shown, }; struct Row { - using Validator = Fn(const QString &value)>; + using Validator = Fn(const QString &value)>; using Formatter = Fn; ValueClass valueClass = ValueClass::Fields; PanelDetailsType inputType = PanelDetailsType(); @@ -87,7 +87,7 @@ public: const QString &scansError, const ValueMap &scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles); PanelEditDocument( QWidget *parent, @@ -96,7 +96,7 @@ public: const QString &scansError, const ValueMap &scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles); PanelEditDocument( QWidget *parent, @@ -119,7 +119,7 @@ private: const QString *scansError, const ValueMap *scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles); not_null setupContent( const QString *error, @@ -127,7 +127,7 @@ private: const QString *scansError, const ValueMap *scansData, ScanListData &&scans, - base::optional &&translations, + std::optional &&translations, std::map &&specialFiles); void updateControlsGeometry(); void updateCommonError(); diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp index 881f0eceb..f91d39ea0 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.cpp @@ -160,10 +160,10 @@ EditScans::List::List( EditScans::List::List( not_null controller, - base::optional &&data) + std::optional &&data) : controller(controller) , files(data ? std::move(data->files) : std::vector()) -, initialCount(data ? base::make_optional(int(files.size())) : base::none) +, initialCount(data ? base::make_optional(int(files.size())) : std::nullopt) , errorMissing(data ? std::move(data->errorMissing) : QString()) { } @@ -232,7 +232,7 @@ void EditScans::List::toggleError(bool shown) { void EditScans::List::errorAnimationCallback() { const auto error = errorAnimation.current(errorShown ? 1. : 0.); if (error == 0.) { - upload->setColorOverride(base::none); + upload->setColorOverride(std::nullopt); } else { upload->setColorOverride(anim::color( st::passportUploadButton.textFg, @@ -428,7 +428,7 @@ EditScans::EditScans( const QString &header, const QString &error, ScanListData &&scans, - base::optional &&translations) + std::optional &&translations) : RpWidget(parent) , _controller(controller) , _error(error) @@ -444,7 +444,7 @@ EditScans::EditScans( const QString &header, const QString &error, std::map &&specialFiles, - base::optional &&translations) + std::optional &&translations) : RpWidget(parent) , _controller(controller) , _error(error) @@ -454,8 +454,8 @@ EditScans::EditScans( setupSpecialScans(header, std::move(specialFiles)); } -base::optional EditScans::validateGetErrorTop() { - auto result = base::optional(); +std::optional EditScans::validateGetErrorTop() { + auto result = std::optional(); const auto suggestResult = [&](int value) { if (!result || *result > value) { result = value; @@ -828,12 +828,12 @@ void EditScans::createSpecialScanRow( row->deleteClicks( ) | rpl::start_with_next([=] { - _controller->deleteScan(type, base::none); + _controller->deleteScan(type, std::nullopt); }, row->lifetime()); row->restoreClicks( ) | rpl::start_with_next([=] { - _controller->restoreScan(type, base::none); + _controller->restoreScan(type, std::nullopt); }, row->lifetime()); scan.rowCreated = !info.deleted; @@ -974,7 +974,7 @@ void EditScans::specialScanErrorAnimationCallback(FileType type) { const auto error = scan.errorAnimation.current( scan.errorShown ? 1. : 0.); if (error == 0.) { - scan.upload->setColorOverride(base::none); + scan.upload->setColorOverride(std::nullopt); } else { scan.upload->setColorOverride(anim::color( st::passportUploadButton.textFg, diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_scans.h b/Telegram/SourceFiles/passport/passport_panel_edit_scans.h index c5c0a0faf..676ccef87 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_scans.h +++ b/Telegram/SourceFiles/passport/passport_panel_edit_scans.h @@ -51,16 +51,16 @@ public: const QString &header, const QString &error, ScanListData &&scans, - base::optional &&translations); + std::optional &&translations); EditScans( QWidget *parent, not_null controller, const QString &header, const QString &error, std::map &&specialFiles, - base::optional &&translations); + std::optional &&translations); - base::optional validateGetErrorTop(); + std::optional validateGetErrorTop(); void scanFieldsChanged(bool changed); @@ -78,7 +78,7 @@ private: List(not_null controller, ScanListData &&data); List( not_null controller, - base::optional &&data = base::none); + std::optional &&data = std::nullopt); bool uploadedSomeMore() const; bool uploadMoreRequired() const; @@ -92,7 +92,7 @@ private: not_null controller; std::vector files; - base::optional initialCount; + std::optional initialCount; QString errorMissing; QPointer> divider; QPointer> header; diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index aad5fecf2..e3b565925 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -29,7 +29,7 @@ namespace { constexpr auto kIgnoreActivationTimeoutMs = 500; -base::optional ApplicationIsActive; +std::optional ApplicationIsActive; } // namespace diff --git a/Telegram/SourceFiles/platform/win/launcher_win.cpp b/Telegram/SourceFiles/platform/win/launcher_win.cpp index 9297a0f2f..8d0309701 100644 --- a/Telegram/SourceFiles/platform/win/launcher_win.cpp +++ b/Telegram/SourceFiles/platform/win/launcher_win.cpp @@ -40,7 +40,7 @@ Launcher::Launcher(int argc, char *argv[]) : Core::Launcher(argc, argv, DeviceModel(), SystemVersion()) { } -base::optional Launcher::readArgumentsHook( +std::optional Launcher::readArgumentsHook( int argc, char *argv[]) const { auto count = 0; @@ -55,7 +55,7 @@ base::optional Launcher::readArgumentsHook( return result; } } - return base::none; + return std::nullopt; } bool Launcher::launchUpdater(UpdaterLaunch action) { diff --git a/Telegram/SourceFiles/platform/win/launcher_win.h b/Telegram/SourceFiles/platform/win/launcher_win.h index 49811bf65..87db62e6e 100644 --- a/Telegram/SourceFiles/platform/win/launcher_win.h +++ b/Telegram/SourceFiles/platform/win/launcher_win.h @@ -16,7 +16,7 @@ public: Launcher(int argc, char *argv[]); private: - base::optional readArgumentsHook( + std::optional readArgumentsHook( int argc, char *argv[]) const override; diff --git a/Telegram/SourceFiles/rpl/combine.h b/Telegram/SourceFiles/rpl/combine.h index 3b5946182..f7a1b018d 100644 --- a/Telegram/SourceFiles/rpl/combine.h +++ b/Telegram/SourceFiles/rpl/combine.h @@ -21,17 +21,17 @@ namespace details { template struct combine_state { - combine_state() : accumulated(std::tuple...>()) { + combine_state() : accumulated(std::tuple...>()) { } - base::optional...>> accumulated; - base::optional> latest; + std::optional...>> accumulated; + std::optional> latest; int invalid = sizeof...(Values); int working = sizeof...(Values); }; template inline std::tuple combine_make_first( - std::tuple...> &&accumulated, + std::tuple...> &&accumulated, std::index_sequence) { return std::make_tuple(std::move(*std::get(accumulated))...); } @@ -65,7 +65,7 @@ public: state->latest = combine_make_first( std::move(*state->accumulated), std::make_index_sequence()); - state->accumulated = base::none; + state->accumulated = std::nullopt; consumer.put_next_copy(*state->latest); } } @@ -276,7 +276,7 @@ namespace details { template struct combine_vector_state { - std::vector> accumulated; + std::vector> accumulated; std::vector latest; int invalid = 0; int working = 0; diff --git a/Telegram/SourceFiles/rpl/combine_previous.h b/Telegram/SourceFiles/rpl/combine_previous.h index 8f89895c9..d4c448a14 100644 --- a/Telegram/SourceFiles/rpl/combine_previous.h +++ b/Telegram/SourceFiles/rpl/combine_previous.h @@ -22,7 +22,7 @@ public: initial = std::move(initial) ](const auto &consumer) mutable { auto previous = consumer.template make_state< - base::optional + std::optional >(); return std::move(initial).start( [consumer, previous](auto &&value) { diff --git a/Telegram/SourceFiles/rpl/distinct_until_changed.h b/Telegram/SourceFiles/rpl/distinct_until_changed.h index 6d8bbc8f6..a81d00ce7 100644 --- a/Telegram/SourceFiles/rpl/distinct_until_changed.h +++ b/Telegram/SourceFiles/rpl/distinct_until_changed.h @@ -22,7 +22,7 @@ public: initial = std::move(initial) ](const auto &consumer) mutable { auto previous = consumer.template make_state< - base::optional + std::optional >(); return std::move(initial).start( [consumer, previous](auto &&value) { diff --git a/Telegram/SourceFiles/rpl/filter.h b/Telegram/SourceFiles/rpl/filter.h index d2a906662..08d11ba74 100644 --- a/Telegram/SourceFiles/rpl/filter.h +++ b/Telegram/SourceFiles/rpl/filter.h @@ -95,13 +95,13 @@ private: template inline const Value &deref_optional_helper( - const base::optional &value) { + const std::optional &value) { return *value; } template inline Value &&deref_optional_helper( - base::optional &&value) { + std::optional &&value) { return std::move(*value); } @@ -109,7 +109,7 @@ class filter_optional_helper { public: template auto operator()(producer< - base::optional, + std::optional, Error, Generator> &&initial) const { return make_producer([ diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 0a63d5110..77be48192 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -55,6 +55,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include #include +#include #include #ifdef Q_OS_WIN diff --git a/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.cpp b/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.cpp index b616f6ebf..432aa0d5e 100644 --- a/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.cpp +++ b/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.cpp @@ -30,7 +30,7 @@ bool BinlogWrapper::failed() const { return _failed; } -base::optional BinlogWrapper::ReadHeader( +std::optional BinlogWrapper::ReadHeader( File &binlog, const Settings &settings) { auto result = BasicHeader(); diff --git a/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.h b/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.h index d5b382878..379f5742d 100644 --- a/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.h +++ b/Telegram/SourceFiles/storage/cache/storage_cache_binlog_reader.h @@ -26,7 +26,7 @@ public: bool finished() const; bool failed() const; - static base::optional ReadHeader( + static std::optional ReadHeader( File &binlog, const Settings &settings); diff --git a/Telegram/SourceFiles/storage/cache/storage_cache_database_object.cpp b/Telegram/SourceFiles/storage/cache/storage_cache_database_object.cpp index a41b1a97e..9bc0c7b61 100644 --- a/Telegram/SourceFiles/storage/cache/storage_cache_database_object.cpp +++ b/Telegram/SourceFiles/storage/cache/storage_cache_database_object.cpp @@ -814,7 +814,7 @@ void DatabaseObject::put( } template -base::optional DatabaseObject::writeKeyPlaceGeneric( +std::optional DatabaseObject::writeKeyPlaceGeneric( StoreRecord &&record, const Key &key, const TaggedValue &value, @@ -856,7 +856,7 @@ base::optional DatabaseObject::writeKeyPlaceGeneric( return result; } -base::optional DatabaseObject::writeKeyPlace( +std::optional DatabaseObject::writeKeyPlace( const Key &key, const TaggedValue &data, uint32 checksum) { diff --git a/Telegram/SourceFiles/storage/cache/storage_cache_database_object.h b/Telegram/SourceFiles/storage/cache/storage_cache_database_object.h index 2014ff1a8..8f1ea3cfb 100644 --- a/Telegram/SourceFiles/storage/cache/storage_cache_database_object.h +++ b/Telegram/SourceFiles/storage/cache/storage_cache_database_object.h @@ -187,12 +187,12 @@ private: bool isFreePlace(PlaceId place) const; template - base::optional writeKeyPlaceGeneric( + std::optional writeKeyPlaceGeneric( StoreRecord &&record, const Key &key, const TaggedValue &value, uint32 checksum); - base::optional writeKeyPlace( + std::optional writeKeyPlace( const Key &key, const TaggedValue &value, uint32 checksum); diff --git a/Telegram/SourceFiles/storage/cache/storage_cache_types.cpp b/Telegram/SourceFiles/storage/cache/storage_cache_types.cpp index 1cafeff6a..7bec686bd 100644 --- a/Telegram/SourceFiles/storage/cache/storage_cache_types.cpp +++ b/Telegram/SourceFiles/storage/cache/storage_cache_types.cpp @@ -59,14 +59,14 @@ QString VersionFilePath(const QString &base) { return base + QStringLiteral("version"); } -base::optional ReadVersionValue(const QString &base) { +std::optional ReadVersionValue(const QString &base) { QFile file(VersionFilePath(base)); if (!file.open(QIODevice::ReadOnly)) { - return base::none; + return std::nullopt; } const auto bytes = file.read(sizeof(Version)); if (bytes.size() != sizeof(Version)) { - return base::none; + return std::nullopt; } return *reinterpret_cast(bytes.data()); } diff --git a/Telegram/SourceFiles/storage/cache/storage_cache_types.h b/Telegram/SourceFiles/storage/cache/storage_cache_types.h index 9e060629d..80a4b72bd 100644 --- a/Telegram/SourceFiles/storage/cache/storage_cache_types.h +++ b/Telegram/SourceFiles/storage/cache/storage_cache_types.h @@ -111,7 +111,7 @@ using Version = int32; QString ComputeBasePath(const QString &original); QString VersionFilePath(const QString &base); -base::optional ReadVersionValue(const QString &base); +std::optional ReadVersionValue(const QString &base); bool WriteVersionValue(const QString &base, Version value); template diff --git a/Telegram/SourceFiles/storage/file_download.cpp b/Telegram/SourceFiles/storage/file_download.cpp index 85dac952d..477513574 100644 --- a/Telegram/SourceFiles/storage/file_download.cpp +++ b/Telegram/SourceFiles/storage/file_download.cpp @@ -1110,7 +1110,7 @@ void mtpFileLoader::changeCDNParams( makeRequest(offset); } -base::optional mtpFileLoader::cacheKey() const { +std::optional mtpFileLoader::cacheKey() const { if (_urlLocation) { return Data::WebDocumentCacheKey(*_urlLocation); } else if (_location) { @@ -1118,7 +1118,7 @@ base::optional mtpFileLoader::cacheKey() const { } else if (_toCache == LoadToCacheAsWell) { return Data::DocumentCacheKey(_dcId, _id); } - return base::none; + return std::nullopt; } mtpFileLoader::~mtpFileLoader() { @@ -1219,7 +1219,7 @@ void webFileLoader::onError() { cancel(true); } -base::optional webFileLoader::cacheKey() const { +std::optional webFileLoader::cacheKey() const { return Data::UrlCacheKey(_url); } diff --git a/Telegram/SourceFiles/storage/file_download.h b/Telegram/SourceFiles/storage/file_download.h index bf32f16d0..3fe7daadf 100644 --- a/Telegram/SourceFiles/storage/file_download.h +++ b/Telegram/SourceFiles/storage/file_download.h @@ -153,7 +153,7 @@ protected: bool tryLoadLocal(); void loadLocal(const Storage::Cache::Key &key); - virtual base::optional cacheKey() const = 0; + virtual std::optional cacheKey() const = 0; virtual void cancelRequests() = 0; void startLoading(bool loadFirst, bool prior); @@ -257,7 +257,7 @@ private: int limit = 0; QByteArray hash; }; - base::optional cacheKey() const override; + std::optional cacheKey() const override; void cancelRequests() override; int partSize() const; @@ -346,7 +346,7 @@ public: protected: void cancelRequests() override; - base::optional cacheKey() const override; + std::optional cacheKey() const override; bool loadPart() override; QString _url; diff --git a/Telegram/SourceFiles/storage/localimageloader.h b/Telegram/SourceFiles/storage/localimageloader.h index 7179d35fc..cc986ca30 100644 --- a/Telegram/SourceFiles/storage/localimageloader.h +++ b/Telegram/SourceFiles/storage/localimageloader.h @@ -165,7 +165,7 @@ struct SendingAlbum { } TaskId taskId; FullMsgId msgId; - base::optional media; + std::optional media; }; SendingAlbum(); diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index d442c5fd9..36d0d6e8b 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -4232,7 +4232,7 @@ void incrementRecentHashtag(RecentHashtagPack &recent, const QString &tag) { } } -base::optional saveRecentHashtags( +std::optional saveRecentHashtags( Fn getPack, const QString &text) { auto found = false; @@ -4262,7 +4262,7 @@ base::optional saveRecentHashtags( found = true; incrementRecentHashtag(recent, tag); } - return found ? base::make_optional(recent) : base::none; + return found ? base::make_optional(recent) : std::nullopt; } void saveRecentSentHashtags(const QString &text) { diff --git a/Telegram/SourceFiles/storage/storage_encrypted_file.cpp b/Telegram/SourceFiles/storage/storage_encrypted_file.cpp index d0ab58c7a..c2c8d1339 100644 --- a/Telegram/SourceFiles/storage/storage_encrypted_file.cpp +++ b/Telegram/SourceFiles/storage/storage_encrypted_file.cpp @@ -295,7 +295,7 @@ void File::close() { _data.close(); _data.setFileName(QString()); _dataSize = _encryptionOffset = 0; - _state = base::none; + _state = std::nullopt; } bool File::isOpen() const { diff --git a/Telegram/SourceFiles/storage/storage_encrypted_file.h b/Telegram/SourceFiles/storage/storage_encrypted_file.h index 7a03d38d9..f4756b6f4 100644 --- a/Telegram/SourceFiles/storage/storage_encrypted_file.h +++ b/Telegram/SourceFiles/storage/storage_encrypted_file.h @@ -66,7 +66,7 @@ private: int64 _encryptionOffset = 0; int64 _dataSize = 0; - base::optional _state; + std::optional _state; }; diff --git a/Telegram/SourceFiles/storage/storage_feed_messages.cpp b/Telegram/SourceFiles/storage/storage_feed_messages.cpp index 7d797f053..09350a62f 100644 --- a/Telegram/SourceFiles/storage/storage_feed_messages.cpp +++ b/Telegram/SourceFiles/storage/storage_feed_messages.cpp @@ -36,7 +36,7 @@ void FeedMessages::add(FeedMessagesAddSlice &&query) { feedIt->second.addSlice( std::move(query.messageIds), query.noSkipRange, - base::none); + std::nullopt); } void FeedMessages::remove(FeedMessagesRemoveOne &&query) { diff --git a/Telegram/SourceFiles/storage/storage_shared_media.h b/Telegram/SourceFiles/storage/storage_shared_media.h index dab7006cf..e7bd5cbf9 100644 --- a/Telegram/SourceFiles/storage/storage_shared_media.h +++ b/Telegram/SourceFiles/storage/storage_shared_media.h @@ -73,7 +73,7 @@ struct SharedMediaAddSlice { SharedMediaType type, std::vector &&messageIds, MsgRange noSkipRange, - base::optional count = base::none) + std::optional count = std::nullopt) : peerId(peerId) , messageIds(std::move(messageIds)) , noSkipRange(noSkipRange) @@ -85,7 +85,7 @@ struct SharedMediaAddSlice { std::vector messageIds; MsgRange noSkipRange; SharedMediaType type = SharedMediaType::kCount; - base::optional count; + std::optional count; }; diff --git a/Telegram/SourceFiles/storage/storage_sparse_ids_list.cpp b/Telegram/SourceFiles/storage/storage_sparse_ids_list.cpp index 23679c9cd..38f9dbc9e 100644 --- a/Telegram/SourceFiles/storage/storage_sparse_ids_list.cpp +++ b/Telegram/SourceFiles/storage/storage_sparse_ids_list.cpp @@ -93,7 +93,7 @@ template void SparseIdsList::addRange( const Range &messages, MsgRange noSkipRange, - base::optional count, + std::optional count, bool incrementCount) { Expects(!count || !incrementCount); @@ -119,20 +119,20 @@ void SparseIdsList::addRange( void SparseIdsList::addNew(MsgId messageId) { auto range = { messageId }; - addRange(range, { messageId, ServerMaxMsgId }, base::none, true); + addRange(range, { messageId, ServerMaxMsgId }, std::nullopt, true); } void SparseIdsList::addExisting( MsgId messageId, MsgRange noSkipRange) { auto range = { messageId }; - addRange(range, noSkipRange, base::none); + addRange(range, noSkipRange, std::nullopt); } void SparseIdsList::addSlice( std::vector &&messageIds, MsgRange noSkipRange, - base::optional count) { + std::optional count) { addRange(messageIds, noSkipRange, count); } @@ -169,7 +169,7 @@ void SparseIdsList::invalidateBottom() { }); } } - _count = base::none; + _count = std::nullopt; } rpl::producer SparseIdsList::query( diff --git a/Telegram/SourceFiles/storage/storage_sparse_ids_list.h b/Telegram/SourceFiles/storage/storage_sparse_ids_list.h index 46f58d1d2..d247001f4 100644 --- a/Telegram/SourceFiles/storage/storage_sparse_ids_list.h +++ b/Telegram/SourceFiles/storage/storage_sparse_ids_list.h @@ -26,16 +26,16 @@ struct SparseIdsListQuery { }; struct SparseIdsListResult { - base::optional count; - base::optional skippedBefore; - base::optional skippedAfter; + std::optional count; + std::optional skippedBefore; + std::optional skippedAfter; base::flat_set messageIds; }; struct SparseIdsSliceUpdate { const base::flat_set *messages = nullptr; MsgRange range; - base::optional count; + std::optional count; }; class SparseIdsList { @@ -45,7 +45,7 @@ public: void addSlice( std::vector &&messageIds, MsgRange noSkipRange, - base::optional count); + std::optional count); void removeOne(MsgId messageId); void removeAll(); void invalidateBottom(); @@ -84,14 +84,14 @@ private: void addRange( const Range &messages, MsgRange noSkipRange, - base::optional count, + std::optional count, bool incrementCount = false); SparseIdsListResult queryFromSlice( const SparseIdsListQuery &query, const Slice &slice) const; - base::optional _count; + std::optional _count; base::flat_set _slices; rpl::event_stream _sliceUpdated; diff --git a/Telegram/SourceFiles/storage/storage_user_photos.cpp b/Telegram/SourceFiles/storage/storage_user_photos.cpp index 3aa67c3f3..3f58608eb 100644 --- a/Telegram/SourceFiles/storage/storage_user_photos.cpp +++ b/Telegram/SourceFiles/storage/storage_user_photos.cpp @@ -38,7 +38,7 @@ void UserPhotos::List::addSlice( void UserPhotos::List::removeOne(PhotoId photoId) { auto position = ranges::find(_photoIds, photoId); if (position == _photoIds.end()) { - _count = base::none; + _count = std::nullopt; } else { if (_count) { --*_count; @@ -51,7 +51,7 @@ void UserPhotos::List::removeOne(PhotoId photoId) { void UserPhotos::List::removeAfter(PhotoId photoId) { auto position = ranges::find(_photoIds, photoId); if (position == _photoIds.end()) { - _count = base::none; + _count = std::nullopt; _photoIds.clear(); } else { if (_count) { diff --git a/Telegram/SourceFiles/storage/storage_user_photos.h b/Telegram/SourceFiles/storage/storage_user_photos.h index b1dc6fc83..2585afe78 100644 --- a/Telegram/SourceFiles/storage/storage_user_photos.h +++ b/Telegram/SourceFiles/storage/storage_user_photos.h @@ -102,8 +102,8 @@ struct UserPhotosQuery { }; struct UserPhotosResult { - base::optional count; - base::optional skippedBefore; + std::optional count; + std::optional skippedBefore; int skippedAfter = 0; std::deque photoIds; }; @@ -112,7 +112,7 @@ struct UserPhotosSliceUpdate { UserPhotosSliceUpdate( UserId userId, const std::deque *photoIds, - base::optional count) + std::optional count) : userId(userId) , photoIds(photoIds) , count(count) { @@ -120,7 +120,7 @@ struct UserPhotosSliceUpdate { UserId userId = 0; const std::deque *photoIds = nullptr; - base::optional count; + std::optional count; }; class UserPhotos { @@ -146,14 +146,14 @@ private: struct SliceUpdate { const std::deque *photoIds = nullptr; - base::optional count; + std::optional count; }; rpl::producer sliceUpdated() const; private: void sendUpdate(); - base::optional _count; + std::optional _count; std::deque _photoIds; rpl::event_stream _sliceUpdated; diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index 39fc48dac..58b5c6733 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -917,8 +917,8 @@ void Image::restore() const { _forgot = false; } -base::optional Image::cacheKey() const { - return base::none; +std::optional Image::cacheKey() const { + return std::nullopt; } void Image::invalidateSizeCache() const { @@ -995,7 +995,7 @@ void RemoteImage::destroyLoaderDelayed(FileLoader *newValue) const { void RemoteImage::loadLocal() { if (loaded() || amLoading()) return; - _loader = createLoader(base::none, LoadFromLocalOnly, true); + _loader = createLoader(std::nullopt, LoadFromLocalOnly, true); if (_loader) _loader->start(); } @@ -1138,9 +1138,9 @@ StorageImage::StorageImage( setImageBytes(bytes); } -base::optional StorageImage::cacheKey() const { +std::optional StorageImage::cacheKey() const { return _location.isNull() - ? base::none + ? std::nullopt : base::make_optional(Data::StorageCacheKey(_location)); } @@ -1195,9 +1195,9 @@ WebFileImage::WebFileImage( , _size(size) { } -base::optional WebFileImage::cacheKey() const { +std::optional WebFileImage::cacheKey() const { return _location.isNull() - ? base::none + ? std::nullopt : base::make_optional(Data::WebDocumentCacheKey(_location)); } @@ -1339,7 +1339,7 @@ WebImage::WebImage(const QString &url, int width, int height) , _height(height) { } -base::optional WebImage::cacheKey() const { +std::optional WebImage::cacheKey() const { return Data::UrlCacheKey(_url); } diff --git a/Telegram/SourceFiles/ui/images.h b/Telegram/SourceFiles/ui/images.h index d90d9a635..7b1205968 100644 --- a/Telegram/SourceFiles/ui/images.h +++ b/Telegram/SourceFiles/ui/images.h @@ -378,7 +378,7 @@ public: virtual const StorageImageLocation &location() const { return StorageImageLocation::Null; } - virtual base::optional cacheKey() const; + virtual std::optional cacheKey() const; bool isNull() const; @@ -516,7 +516,7 @@ public: const StorageImageLocation &location() const override { return _location; } - base::optional cacheKey() const override; + std::optional cacheKey() const override; void refreshFileReference(const QByteArray &data) { _location.refreshFileReference(data); } @@ -545,7 +545,7 @@ public: int height, int size = 0); - base::optional cacheKey() const override; + std::optional cacheKey() const override; protected: void setInformation(int size, int width, int height) override; @@ -619,7 +619,7 @@ public: void setSize(int width, int height); - base::optional cacheKey() const override; + std::optional cacheKey() const override; protected: QSize shrinkBox() const override { diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index 6ec7b063e..e072b8449 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -1004,7 +1004,7 @@ void SilentToggle::mouseReleaseEvent(QMouseEvent *e) { Ui::Tooltip::Show(0, this); Auth().data().updateNotifySettings( _channel, - base::none, + std::nullopt, _checked); } diff --git a/Telegram/SourceFiles/ui/widgets/buttons.cpp b/Telegram/SourceFiles/ui/widgets/buttons.cpp index dd60bd69a..ea7d8ca4f 100644 --- a/Telegram/SourceFiles/ui/widgets/buttons.cpp +++ b/Telegram/SourceFiles/ui/widgets/buttons.cpp @@ -60,7 +60,7 @@ void LinkButton::setText(const QString &text) { update(); } -void LinkButton::setColorOverride(base::optional textFg) { +void LinkButton::setColorOverride(std::optional textFg) { _textFgOverride = textFg; update(); } diff --git a/Telegram/SourceFiles/ui/widgets/buttons.h b/Telegram/SourceFiles/ui/widgets/buttons.h index 3256a799d..115c45c9a 100644 --- a/Telegram/SourceFiles/ui/widgets/buttons.h +++ b/Telegram/SourceFiles/ui/widgets/buttons.h @@ -24,7 +24,7 @@ public: int naturalWidth() const override; void setText(const QString &text); - void setColorOverride(base::optional textFg); + void setColorOverride(std::optional textFg); protected: void paintEvent(QPaintEvent *e) override; @@ -35,7 +35,7 @@ private: const style::LinkButton &_st; QString _text; int _textWidth = 0; - base::optional _textFgOverride; + std::optional _textFgOverride; }; diff --git a/Telegram/SourceFiles/ui/widgets/checkbox.cpp b/Telegram/SourceFiles/ui/widgets/checkbox.cpp index 552d52892..ad0c84d15 100644 --- a/Telegram/SourceFiles/ui/widgets/checkbox.cpp +++ b/Telegram/SourceFiles/ui/widgets/checkbox.cpp @@ -258,7 +258,7 @@ bool CheckView::checkRippleStartPosition(QPoint position) const { } void CheckView::setUntoggledOverride( - base::optional untoggledOverride) { + std::optional untoggledOverride) { _untoggledOverride = untoggledOverride; update(); } @@ -328,7 +328,7 @@ bool RadioView::checkRippleStartPosition(QPoint position) const { } void RadioView::setUntoggledOverride( - base::optional untoggledOverride) { + std::optional untoggledOverride) { _untoggledOverride = untoggledOverride; update(); } diff --git a/Telegram/SourceFiles/ui/widgets/checkbox.h b/Telegram/SourceFiles/ui/widgets/checkbox.h index 656756392..5a00d6cb3 100644 --- a/Telegram/SourceFiles/ui/widgets/checkbox.h +++ b/Telegram/SourceFiles/ui/widgets/checkbox.h @@ -71,13 +71,13 @@ public: bool checkRippleStartPosition(QPoint position) const override; void setUntoggledOverride( - base::optional untoggledOverride); + std::optional untoggledOverride); private: QSize rippleSize() const; not_null _st; - base::optional _untoggledOverride; + std::optional _untoggledOverride; }; @@ -90,7 +90,7 @@ public: void setStyle(const style::Radio &st); - void setUntoggledOverride(base::optional untoggledOverride); + void setUntoggledOverride(std::optional untoggledOverride); QSize getSize() const override; void paint(Painter &p, int left, int top, int outerWidth, TimeMs ms) override; @@ -101,7 +101,7 @@ private: QSize rippleSize() const; not_null _st; - base::optional _untoggledOverride; + std::optional _untoggledOverride; }; diff --git a/Telegram/SourceFiles/ui/widgets/input_fields.cpp b/Telegram/SourceFiles/ui/widgets/input_fields.cpp index 49186159a..d89922f5c 100644 --- a/Telegram/SourceFiles/ui/widgets/input_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/input_fields.cpp @@ -2852,7 +2852,7 @@ void InputField::commitInstantReplacement( int from, int till, const QString &with, - base::optional checkOriginal) { + std::optional checkOriginal) { const auto original = getTextWithTagsPart(from, till).text; if (checkOriginal && checkOriginal->compare(original, Qt::CaseInsensitive) != 0) { diff --git a/Telegram/SourceFiles/ui/widgets/input_fields.h b/Telegram/SourceFiles/ui/widgets/input_fields.h index 7b4b098b5..863fd1171 100644 --- a/Telegram/SourceFiles/ui/widgets/input_fields.h +++ b/Telegram/SourceFiles/ui/widgets/input_fields.h @@ -221,7 +221,7 @@ public: int from, int till, const QString &with, - base::optional checkOriginal = base::none); + std::optional checkOriginal = std::nullopt); bool commitMarkdownReplacement( int from, int till, diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index 615e4e08a..f6f48084e 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -179,7 +179,7 @@ TermsLock TermsLock::FromMTP(const MTPDhelp_termsOfService &data) { TextUtilities::EntitiesFromMTP(data.ventities.v) }, (data.has_min_age_confirm() ? base::make_optional(data.vmin_age_confirm.v) - : base::none), + : std::nullopt), data.is_popup() }; } @@ -200,7 +200,7 @@ TermsBox::TermsBox( Fn agree, Fn cancel, bool attentionAgree) -: _data{ {}, text, base::none, false } +: _data{ {}, text, std::nullopt, false } , _agree(agree) , _cancel(cancel) , _attentionAgree(attentionAgree) { @@ -263,7 +263,7 @@ void TermsBox::prepare() { const auto error = _ageErrorAnimation.current( _ageErrorShown ? 1. : 0.); if (error == 0.) { - check->setUntoggledOverride(base::none); + check->setUntoggledOverride(std::nullopt); } else { const auto color = anim::color( st::defaultCheck.untoggledFg, diff --git a/Telegram/SourceFiles/window/window_lock_widgets.h b/Telegram/SourceFiles/window/window_lock_widgets.h index f04e64deb..3b9a56e5b 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.h +++ b/Telegram/SourceFiles/window/window_lock_widgets.h @@ -66,7 +66,7 @@ private: struct TermsLock { bytes::vector id; TextWithEntities text; - base::optional minAge; + std::optional minAge; bool popup = false; inline bool operator==(const TermsLock &other) const {