diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 1e30b38aaa..44128028ff 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2186,7 +2186,7 @@ namespace { cors[3] = rect.copy(r * 2, r * 2, r, r + (shadow ? s : 0)); if (index != SmallMaskCorners && index != LargeMaskCorners) { for (int i = 0; i < 4; ++i) { - ::corners[index].p[i] = new QPixmap(pixmapFromImageInPlace(std_::move(cors[i]))); + ::corners[index].p[i] = new QPixmap(pixmapFromImageInPlace(std::move(cors[i]))); ::corners[index].p[i]->setDevicePixelRatio(cRetinaFactor()); } } @@ -2424,7 +2424,7 @@ namespace { QPainter p(&image); emojiDraw(p, emoji, st::emojiPadding * cIntRetinaFactor(), (fontHeight * cIntRetinaFactor() - Ui::Emoji::Size()) / 2); } - i = map.insert(emoji->index(), App::pixmapFromImageInPlace(std_::move(image))); + i = map.insert(emoji->index(), App::pixmapFromImageInPlace(std::move(image))); } return i.value(); } @@ -2550,7 +2550,7 @@ namespace { } #endif // OS_MAC_OLD } else if (opaque) { - result = Images::prepareOpaque(std_::move(result)); + result = Images::prepareOpaque(std::move(result)); } return result; } @@ -2570,7 +2570,7 @@ namespace { } QPixmap pixmapFromImageInPlace(QImage &&image) { - return QPixmap::fromImage(std_::move(image), Qt::ColorOnly); + return QPixmap::fromImage(std::move(image), Qt::ColorOnly); } void regPhotoItem(PhotoData *data, HistoryItem *item) { @@ -2860,7 +2860,7 @@ namespace { CornersPixmaps pixmaps; for (int j = 0; j < 4; ++j) { - pixmaps.p[j] = new QPixmap(pixmapFromImageInPlace(std_::move(images[j]))); + pixmaps.p[j] = new QPixmap(pixmapFromImageInPlace(std::move(images[j]))); pixmaps.p[j]->setDevicePixelRatio(cRetinaFactor()); } i = cornersMap.insert(colorKey, pixmaps); diff --git a/Telegram/SourceFiles/boxes/abstractbox.cpp b/Telegram/SourceFiles/boxes/abstractbox.cpp index 4b07004bb9..1936c59bac 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.cpp +++ b/Telegram/SourceFiles/boxes/abstractbox.cpp @@ -34,15 +34,15 @@ BoxLayerTitleShadow::BoxLayerTitleShadow(QWidget *parent) : Ui::PlainShadow(pare } QPointer BoxContent::addButton(const QString &text, base::lambda &&clickCallback) { - return addButton(text, std_::move(clickCallback), st::defaultBoxButton); + return addButton(text, std::move(clickCallback), st::defaultBoxButton); } QPointer BoxContent::addLeftButton(const QString &text, base::lambda &&clickCallback) { - return getDelegate()->addLeftButton(text, std_::move(clickCallback), st::defaultBoxButton); + return getDelegate()->addLeftButton(text, std::move(clickCallback), st::defaultBoxButton); } void BoxContent::setInner(object_ptr inner) { - setInner(std_::move(inner), st::boxLayerScroll); + setInner(std::move(inner), st::boxLayerScroll); } void BoxContent::setInner(object_ptr inner, const style::ScrollArea &st) { @@ -50,7 +50,7 @@ void BoxContent::setInner(object_ptr inner, const style::ScrollArea &st getDelegate()->setLayerType(true); _scroll.create(this, st); _scroll->setGeometryToLeft(0, _innerTopSkip, width(), 0); - _scroll->setOwnedWidget(std_::move(inner)); + _scroll->setOwnedWidget(std::move(inner)); if (_topShadow) { _topShadow->raise(); _bottomShadow->raise(); @@ -155,7 +155,7 @@ QPixmap BoxContent::grabInnerCache() { auto result = myGrab(this, _scroll->geometry()); if (isTopShadowVisible) _topShadow->show(); if (isBottomShadowVisible) _bottomShadow->show(); - return std_::move(result); + return std::move(result); } void BoxContent::resizeEvent(QResizeEvent *e) { @@ -197,14 +197,14 @@ void BoxContent::paintEvent(QPaintEvent *e) { Painter p(this); if (testAttribute(Qt::WA_OpaquePaintEvent)) { - for_const (auto rect, e->region().rects()) { + for (auto rect : e->region().rects()) { p.fillRect(rect, st::boxBg); } } } AbstractBox::AbstractBox(QWidget *parent, object_ptr content) : LayerWidget(parent) -, _content(std_::move(content)) { +, _content(std::move(content)) { _content->setParent(this); _content->setDelegate(this); } @@ -240,7 +240,7 @@ void AbstractBox::paintEvent(QPaintEvent *e) { } auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius)); if (!other.isEmpty()) { - for_const (auto rect, other.rects()) { + for (auto rect : other.rects()) { p.fillRect(rect, st::boxBg); } } @@ -289,7 +289,7 @@ void AbstractBox::updateSize() { } void AbstractBox::updateButtonsPositions() { - if (!_buttons.isEmpty() || _leftButton) { + if (!_buttons.empty() || _leftButton) { auto padding = _layerType ? st::boxLayerButtonPadding : st::boxButtonPadding; auto right = padding.right(); auto top = buttonsTop(); @@ -313,7 +313,7 @@ void AbstractBox::clearButtons() { QPointer AbstractBox::addButton(const QString &text, base::lambda &&clickCallback, const style::RoundButton &st) { _buttons.push_back(object_ptr(this, text, st)); auto result = QPointer(_buttons.back()); - result->setClickedCallback(std_::move(clickCallback)); + result->setClickedCallback(std::move(clickCallback)); result->show(); updateButtonsPositions(); return result; @@ -322,7 +322,7 @@ QPointer AbstractBox::addButton(const QString &text, base::lamb QPointer AbstractBox::addLeftButton(const QString &text, base::lambda &&clickCallback, const style::RoundButton &st) { _leftButton = object_ptr(this, text, st); auto result = QPointer(_leftButton); - result->setClickedCallback(std_::move(clickCallback)); + result->setClickedCallback(std::move(clickCallback)); result->show(); updateButtonsPositions(); return result; diff --git a/Telegram/SourceFiles/boxes/abstractbox.h b/Telegram/SourceFiles/boxes/abstractbox.h index 0fc187186d..6e5150b02d 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.h +++ b/Telegram/SourceFiles/boxes/abstractbox.h @@ -101,7 +101,7 @@ protected: QPointer addButton(const QString &text, base::lambda &&clickCallback); QPointer addLeftButton(const QString &text, base::lambda &&clickCallback); QPointer addButton(const QString &text, base::lambda &&clickCallback, const style::RoundButton &st) { - return getDelegate()->addButton(text, std_::move(clickCallback), st); + return getDelegate()->addButton(text, std::move(clickCallback), st); } void updateButtonsGeometry() { getDelegate()->updateButtonsPositions(); @@ -123,7 +123,7 @@ protected: QPointer setInnerWidget(object_ptr inner, const style::ScrollArea &st, int topSkip = 0) { auto result = QPointer(inner.data()); setInnerTopSkip(topSkip); - setInner(std_::move(inner), st); + setInner(std::move(inner), st); return result; } @@ -131,7 +131,7 @@ protected: QPointer setInnerWidget(object_ptr inner, int topSkip = 0) { auto result = QPointer(inner.data()); setInnerTopSkip(topSkip); - setInner(std_::move(inner)); + setInner(std::move(inner)); return result; } @@ -241,7 +241,7 @@ private: QString _additionalTitle; bool _layerType = false; - std_::vector_of_moveable> _buttons; + std::vector> _buttons; object_ptr _leftButton = { nullptr }; }; diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 3dc25907fa..11c9cc741a 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -1115,7 +1115,7 @@ RevokePublicLinkBox::RevokePublicLinkBox(QWidget*, base::lambda &&revoke : _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke))) , _aboutRevoke(this, lang(lng_channels_too_much_public_about), Ui::FlatLabel::InitType::Simple, st::aboutRevokePublicLabel) -, _revokeCallback(std_::move(revokeCallback)) { +, _revokeCallback(std::move(revokeCallback)) { } void RevokePublicLinkBox::prepare() { @@ -1231,7 +1231,7 @@ void RevokePublicLinkBox::getPublicDone(const MTPmessages_Chats &result) { row.peer = peer; row.name.setText(st::contactsNameStyle, peer->name, _textNameOptions); row.status.setText(st::defaultTextStyle, CreateInternalLink(textcmdLink(1, peer->userName())), _textDlgOptions); - _rows.push_back(std_::move(row)); + _rows.push_back(std::move(row)); } } } diff --git a/Telegram/SourceFiles/boxes/backgroundbox.cpp b/Telegram/SourceFiles/boxes/backgroundbox.cpp index ba93c0f90c..0cf48bfd76 100644 --- a/Telegram/SourceFiles/boxes/backgroundbox.cpp +++ b/Telegram/SourceFiles/boxes/backgroundbox.cpp @@ -55,7 +55,7 @@ void BackgroundBox::backgroundChosen(int index) { } BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent) -, _check(std_::make_unique(st::overviewCheck, [this] { update(); })) { +, _check(std::make_unique(st::overviewCheck, [this] { update(); })) { _check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast); if (App::cServerBackgrounds().isEmpty()) { resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding); diff --git a/Telegram/SourceFiles/boxes/backgroundbox.h b/Telegram/SourceFiles/boxes/backgroundbox.h index 1c8a2abe75..aa23c3fa44 100644 --- a/Telegram/SourceFiles/boxes/backgroundbox.h +++ b/Telegram/SourceFiles/boxes/backgroundbox.h @@ -47,7 +47,7 @@ public: Inner(QWidget *parent); void setBackgroundChosenCallback(base::lambda &&callback) { - _backgroundChosenCallback = std_::move(callback); + _backgroundChosenCallback = std::move(callback); } ~Inner(); @@ -68,6 +68,6 @@ private: int _rows = 0; int _over = -1; int _overDown = -1; - std_::unique_ptr _check; // this is not a widget + std::unique_ptr _check; // this is not a widget }; diff --git a/Telegram/SourceFiles/boxes/confirmbox.cpp b/Telegram/SourceFiles/boxes/confirmbox.cpp index 07272358c9..f2f8d58518 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.cpp +++ b/Telegram/SourceFiles/boxes/confirmbox.cpp @@ -46,8 +46,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, base::lambda &&con , _cancelText(lang(lng_cancel)) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) -, _confirmedCallback(std_::move(confirmedCallback)) -, _cancelledCallback(std_::move(cancelledCallback)) { +, _confirmedCallback(std::move(confirmedCallback)) +, _cancelledCallback(std::move(cancelledCallback)) { init(text); } @@ -56,8 +56,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText , _cancelText(lang(lng_cancel)) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) -, _confirmedCallback(std_::move(confirmedCallback)) -, _cancelledCallback(std_::move(cancelledCallback)) { +, _confirmedCallback(std::move(confirmedCallback)) +, _cancelledCallback(std::move(cancelledCallback)) { init(text); } @@ -66,8 +66,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText , _cancelText(lang(lng_cancel)) , _confirmStyle(confirmStyle) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) -, _confirmedCallback(std_::move(confirmedCallback)) -, _cancelledCallback(std_::move(cancelledCallback)) { +, _confirmedCallback(std::move(confirmedCallback)) +, _cancelledCallback(std::move(cancelledCallback)) { init(text); } @@ -76,8 +76,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText , _cancelText(cancelText) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) -, _confirmedCallback(std_::move(confirmedCallback)) -, _cancelledCallback(std_::move(cancelledCallback)) { +, _confirmedCallback(std::move(confirmedCallback)) +, _cancelledCallback(std::move(cancelledCallback)) { init(text); } @@ -86,8 +86,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText , _cancelText(cancelText) , _confirmStyle(st::defaultBoxButton) , _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) -, _confirmedCallback(std_::move(confirmedCallback)) -, _cancelledCallback(std_::move(cancelledCallback)) { +, _confirmedCallback(std::move(confirmedCallback)) +, _cancelledCallback(std::move(cancelledCallback)) { init(text); } @@ -212,10 +212,10 @@ void ConfirmBox::paintEvent(QPaintEvent *e) { _text.drawLeftElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, width(), 16, style::al_left); } -InformBox::InformBox(QWidget*, const QString &text, base::lambda_copy &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std_::move(closedCallback)) { +InformBox::InformBox(QWidget*, const QString &text, base::lambda_copy &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) { } -InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda_copy &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std_::move(closedCallback)) { +InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda_copy &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) { } MaxInviteBox::MaxInviteBox(QWidget*, const QString &link) diff --git a/Telegram/SourceFiles/boxes/confirmphonebox.cpp b/Telegram/SourceFiles/boxes/confirmphonebox.cpp index 42370bba97..a2acffd165 100644 --- a/Telegram/SourceFiles/boxes/confirmphonebox.cpp +++ b/Telegram/SourceFiles/boxes/confirmphonebox.cpp @@ -106,7 +106,7 @@ void ConfirmPhoneBox::setCallStatus(const CallStatus &status) { void ConfirmPhoneBox::launch() { if (!CurrentConfirmPhoneBox) return; - Ui::show(std_::move(CurrentConfirmPhoneBox)); + Ui::show(std::move(CurrentConfirmPhoneBox)); } void ConfirmPhoneBox::prepare() { diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index 04cdc011d0..411baf1444 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -293,7 +293,7 @@ object_ptr> ContactsBox::createMultiSelect( auto entity = object_ptr(this, st::contactsMultiSelect, lang(lng_participant_filter)); auto margins = style::margins(0, 0, 0, 0); auto callback = [this] { updateScrollSkips(); }; - return object_ptr>(this, std_::move(entity), margins, std_::move(callback)); + return object_ptr>(this, std::move(entity), margins, std::move(callback)); } int ContactsBox::getTopScrollSkip() const { @@ -528,7 +528,7 @@ bool ContactsBox::creationFail(const RPCError &error) { ContactsBox::Inner::ContactData::ContactData() = default; ContactsBox::Inner::ContactData::ContactData(PeerData *peer, const base::lambda_copy &updateCallback) -: checkbox(std_::make_unique(st::contactsPhotoCheckbox, updateCallback, PaintUserpicCallback(peer))) { +: checkbox(std::make_unique(st::contactsPhotoCheckbox, updateCallback, PaintUserpicCallback(peer))) { } ContactsBox::Inner::ContactData::~ContactData() = default; @@ -568,7 +568,7 @@ ContactsBox::Inner::Inner(QWidget *parent, ChatData *chat, MembersFilter members , _aboutWidth(st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.right()) , _aboutAllAdmins(st::defaultTextStyle, lang(lng_chat_about_all_admins), _defaultOptions, _aboutWidth) , _aboutAdmins(st::defaultTextStyle, lang(lng_chat_about_admins), _defaultOptions, _aboutWidth) -, _customList((membersFilter == MembersFilter::Recent) ? std_::unique_ptr() : std_::make_unique(Dialogs::SortMode::Add)) +, _customList((membersFilter == MembersFilter::Recent) ? std::unique_ptr() : std::make_unique(Dialogs::SortMode::Add)) , _contacts((membersFilter == MembersFilter::Recent) ? App::main()->contactsList() : _customList.get()) , _addContactLnk(this, lang(lng_add_contact_button)) { initList(); @@ -596,7 +596,7 @@ ContactsBox::Inner::Inner(QWidget *parent, UserData *bot) : TWidget(parent) , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _bot(bot) , _allAdmins(this, lang(lng_chat_all_members_admins), false, st::defaultBoxCheckbox) -, _customList(std_::make_unique(Dialogs::SortMode::Add)) +, _customList(std::make_unique(Dialogs::SortMode::Add)) , _contacts(_customList.get()) , _addContactLnk(this, lang(lng_add_contact_button)) { if (sharingBotGame()) { @@ -1297,7 +1297,7 @@ void ContactsBox::Inner::addRipple(PeerData *peer, ContactData *data) { auto rowTop = getSelectedRowTop(); if (!data->ripple) { auto mask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight)); - data->ripple = std_::make_unique(st::contactsRipple, std_::move(mask), [this, data] { + data->ripple = std::make_unique(st::contactsRipple, std::move(mask), [this, data] { updateRowWithTop(data->rippleRowTop); }); } @@ -1471,7 +1471,7 @@ void ContactsBox::Inner::peerUnselected(PeerData *peer) { } void ContactsBox::Inner::setPeerSelectedChangedCallback(base::lambda &&callback) { - _peerSelectedChangedCallback = std_::move(callback); + _peerSelectedChangedCallback = std::move(callback); } void ContactsBox::Inner::changePeerCheckState(ContactData *data, PeerData *peer, bool checked, ChangeStateWay useCallback) { diff --git a/Telegram/SourceFiles/boxes/contactsbox.h b/Telegram/SourceFiles/boxes/contactsbox.h index 5fa5a37a84..b96392faea 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.h +++ b/Telegram/SourceFiles/boxes/contactsbox.h @@ -165,7 +165,7 @@ public: QVector selectedInputs(); bool allAdmins() const; void setAllAdminsChangedCallback(base::lambda &&allAdminsChangedCallback) { - _allAdminsChangedCallback = std_::move(allAdminsChangedCallback); + _allAdminsChangedCallback = std::move(allAdminsChangedCallback); } void chooseParticipant(); @@ -221,8 +221,8 @@ private: ContactData(PeerData *peer, const base::lambda_copy &updateCallback); ~ContactData(); - std_::unique_ptr checkbox; - std_::unique_ptr ripple; + std::unique_ptr checkbox; + std::unique_ptr ripple; int rippleRowTop = 0; Text name; QString statusText; @@ -297,7 +297,7 @@ private: int32 _time; - std_::unique_ptr _customList; + std::unique_ptr _customList; Dialogs::IndexedList *_contacts = nullptr; Dialogs::Row *_selected = nullptr; Dialogs::Row *_pressed = nullptr; diff --git a/Telegram/SourceFiles/boxes/editcolorbox.cpp b/Telegram/SourceFiles/boxes/editcolorbox.cpp index c44992b5b7..4e8cc6c5b0 100644 --- a/Telegram/SourceFiles/boxes/editcolorbox.cpp +++ b/Telegram/SourceFiles/boxes/editcolorbox.cpp @@ -359,9 +359,9 @@ void EditColorBox::Slider::generatePixmap() { ++ints; } if (!isHorizontal()) { - image = std_::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); + image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); } - _pixmap = App::pixmapFromImageInPlace(std_::move(image)); + _pixmap = App::pixmapFromImageInPlace(std::move(image)); } else { auto color = anim::shifted(QColor(255, 255, 255, 255)); auto transparent = anim::shifted(QColor(255, 255, 255, 0)); @@ -377,9 +377,9 @@ void EditColorBox::Slider::generatePixmap() { ints += intsPerLineAdded; } if (!isHorizontal()) { - image = std_::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); + image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); } - _mask = std_::move(image); + _mask = std::move(image); updatePixmapFromMask(); } } diff --git a/Telegram/SourceFiles/boxes/editcolorbox.h b/Telegram/SourceFiles/boxes/editcolorbox.h index 42e92512ac..3dfc2c0b26 100644 --- a/Telegram/SourceFiles/boxes/editcolorbox.h +++ b/Telegram/SourceFiles/boxes/editcolorbox.h @@ -29,11 +29,11 @@ public: EditColorBox(QWidget*, const QString &title, QColor current = QColor(255, 255, 255)); void setSaveCallback(base::lambda &&callback) { - _saveCallback = std_::move(callback); + _saveCallback = std::move(callback); } void setCancelCallback(base::lambda &&callback) { - _cancelCallback = std_::move(callback); + _cancelCallback = std::move(callback); } void showColor(QColor color) { diff --git a/Telegram/SourceFiles/boxes/members_box.cpp b/Telegram/SourceFiles/boxes/members_box.cpp index 3246258c76..f1c428f0ec 100644 --- a/Telegram/SourceFiles/boxes/members_box.cpp +++ b/Telegram/SourceFiles/boxes/members_box.cpp @@ -109,9 +109,9 @@ void MembersBox::onAdd() { } auto box = Box(_inner->channel(), _inner->filter(), _inner->already()); if (_inner->filter() == MembersFilter::Recent) { - Ui::show(std_::move(box)); + Ui::show(std::move(box)); } else { - _addBox = Ui::show(std_::move(box), KeepOtherLayers); + _addBox = Ui::show(std::move(box), KeepOtherLayers); if (_addBox) { connect(_addBox, SIGNAL(adminAdded()), this, SLOT(onAdminAdded())); } @@ -240,7 +240,7 @@ void MembersBox::Inner::addRipple(MemberData *data) { auto rowTop = getSelectedRowTop(); if (!data->ripple) { auto mask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight)); - data->ripple = std_::make_unique(st::contactsRipple, std_::move(mask), [this, data] { + data->ripple = std::make_unique(st::contactsRipple, std::move(mask), [this, data] { updateRowWithTop(data->rippleRowTop); }); } diff --git a/Telegram/SourceFiles/boxes/members_box.h b/Telegram/SourceFiles/boxes/members_box.h index 31ca104ed6..0033a61bf5 100644 --- a/Telegram/SourceFiles/boxes/members_box.h +++ b/Telegram/SourceFiles/boxes/members_box.h @@ -129,7 +129,7 @@ private: MemberData(); ~MemberData(); - std_::unique_ptr ripple; + std::unique_ptr ripple; int rippleRowTop = 0; Text name; QString online; diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp index de0f70e6ec..e4b21c994b 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.cpp +++ b/Telegram/SourceFiles/boxes/notifications_box.cpp @@ -250,7 +250,7 @@ void NotificationsBox::prepareNotificationSampleSmall() { auto closeLeft = width - 2 * padding; p.fillRect(rtlrect(closeLeft, padding, padding, padding, width), st::notificationSampleCloseFg); } - _notificationSampleSmall = App::pixmapFromImageInPlace(std_::move(sampleImage)); + _notificationSampleSmall = App::pixmapFromImageInPlace(std::move(sampleImage)); _notificationSampleSmall.setDevicePixelRatio(cRetinaFactor()); } @@ -294,7 +294,7 @@ void NotificationsBox::prepareNotificationSampleLarge() { st::notifyClose.icon.paint(p, w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPosition.x(), st::notifyClosePos.y() + st::notifyClose.iconPosition.y(), w); } - _notificationSampleLarge = App::pixmapFromImageInPlace(std_::move(sampleImage)); + _notificationSampleLarge = App::pixmapFromImageInPlace(std::move(sampleImage)); } void NotificationsBox::removeSample(SampleWidget *widget) { @@ -366,7 +366,7 @@ void NotificationsBox::setOverCorner(Notify::ScreenCorner corner) { auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX); auto sampleTop = isTop ? (r.y() + st::notifyDeltaY) : (r.y() + r.height() - st::notifyDeltaY - st::notifyMinHeight); for (int i = samplesLeave; i != samplesNeeded; ++i) { - auto widget = std_::make_unique(this, _notificationSampleLarge); + auto widget = std::make_unique(this, _notificationSampleLarge); widget->move(sampleLeft, sampleTop + (isTop ? 1 : -1) * i * (st::notifyMinHeight + st::notifyDeltaY)); widget->showFast(); samples.push_back(widget.release()); diff --git a/Telegram/SourceFiles/boxes/notifications_box.h b/Telegram/SourceFiles/boxes/notifications_box.h index 7dfc824820..910787edcb 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.h +++ b/Telegram/SourceFiles/boxes/notifications_box.h @@ -63,7 +63,7 @@ private: QPixmap _notificationSampleSmall; QPixmap _notificationSampleLarge; ScreenCorner _chosenCorner; - std_::vector_of_moveable _sampleOpacities; + std::vector _sampleOpacities; bool _isOverCorner = false; ScreenCorner _overCorner = ScreenCorner::TopLeft; diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 45f2fd1fc7..f3254930aa 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -93,9 +93,9 @@ SendFilesBox::SendFilesBox(QWidget*, const QString &filepath, QImage image, Comp } _previewLeft = (st::boxWideWidth - _previewWidth) / 2; - image = std_::move(image).scaled(_previewWidth * cIntRetinaFactor(), _previewHeight * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - image = Images::prepareOpaque(std_::move(image)); - _preview = App::pixmapFromImageInPlace(std_::move(image)); + image = std::move(image).scaled(_previewWidth * cIntRetinaFactor(), _previewHeight * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + image = Images::prepareOpaque(std::move(image)); + _preview = App::pixmapFromImageInPlace(std::move(image)); _preview.setDevicePixelRatio(cRetinaFactor()); } } diff --git a/Telegram/SourceFiles/boxes/send_files_box.h b/Telegram/SourceFiles/boxes/send_files_box.h index 7cd4cfdeb0..ea8c805e2a 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.h +++ b/Telegram/SourceFiles/boxes/send_files_box.h @@ -38,10 +38,10 @@ public: SendFilesBox(QWidget*, const QString &phone, const QString &firstname, const QString &lastname); void setConfirmedCallback(base::lambda &&callback) { - _confirmedCallback = std_::move(callback); + _confirmedCallback = std::move(callback); } void setCancelledCallback(base::lambda &&callback) { - _cancelledCallback = std_::move(callback); + _cancelledCallback = std::move(callback); } void closeHook() override; diff --git a/Telegram/SourceFiles/boxes/sharebox.cpp b/Telegram/SourceFiles/boxes/sharebox.cpp index 5e9bc31248..af662783cd 100644 --- a/Telegram/SourceFiles/boxes/sharebox.cpp +++ b/Telegram/SourceFiles/boxes/sharebox.cpp @@ -41,9 +41,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "boxes/contactsbox.h" ShareBox::ShareBox(QWidget*, CopyCallback &©Callback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback) -: _copyCallback(std_::move(copyCallback)) -, _submitCallback(std_::move(submitCallback)) -, _filterCallback(std_::move(filterCallback)) +: _copyCallback(std::move(copyCallback)) +, _submitCallback(std::move(submitCallback)) +, _filterCallback(std::move(filterCallback)) , _select(this, st::contactsMultiSelect, lang(lng_participant_filter)) , _searchTimer(this) { } @@ -54,7 +54,7 @@ void ShareBox::prepare() { setTitle(lang(lng_share_title)); - _inner = setInnerWidget(object_ptr(this, std_::move(_filterCallback)), getTopScrollSkip()); + _inner = setInnerWidget(object_ptr(this, std::move(_filterCallback)), getTopScrollSkip()); connect(_inner, SIGNAL(mustScrollTo(int,int)), this, SLOT(onMustScrollTo(int,int))); createButtons(); @@ -272,8 +272,8 @@ void ShareBox::scrollAnimationCallback() { } ShareBox::Inner::Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback) : TWidget(parent) -, _filterCallback(std_::move(filterCallback)) -, _chatsIndexed(std_::make_unique(Dialogs::SortMode::Add)) { +, _filterCallback(std::move(filterCallback)) +, _chatsIndexed(std::make_unique(Dialogs::SortMode::Add)) { _rowsTop = st::shareRowsTop; _rowHeight = st::shareRowHeight; setAttribute(Qt::WA_OpaquePaintEvent); @@ -649,7 +649,7 @@ void ShareBox::Inner::peerUnselected(PeerData *peer) { } void ShareBox::Inner::setPeerSelectedChangedCallback(base::lambda &&callback) { - _peerSelectedChangedCallback = std_::move(callback); + _peerSelectedChangedCallback = std::move(callback); } void ShareBox::Inner::changePeerCheckState(Chat *chat, bool checked, ChangeStateWay useCallback) { @@ -903,7 +903,7 @@ void shareGameScoreFromItem(HistoryItem *item) { MTPVector random = MTP_vector(1, rand_value()); auto request = MTPmessages_ForwardMessages(MTP_flags(sendFlags), item->history()->peer->input, msgIds, random, peer->input); auto callback = doneCallback; - auto requestId = MTP::send(request, rpcDone(std_::move(callback))); + auto requestId = MTP::send(request, rpcDone(std::move(callback))); data->requests.insert(requestId); } } @@ -918,7 +918,7 @@ void shareGameScoreFromItem(HistoryItem *item) { } return false; }; - Ui::show(Box(std_::move(copyCallback), std_::move(submitCallback), std_::move(filterCallback))); + Ui::show(Box(std::move(copyCallback), std::move(submitCallback), std::move(filterCallback))); } } // namespace diff --git a/Telegram/SourceFiles/boxes/sharebox.h b/Telegram/SourceFiles/boxes/sharebox.h index 523da41b15..d0a396e811 100644 --- a/Telegram/SourceFiles/boxes/sharebox.h +++ b/Telegram/SourceFiles/boxes/sharebox.h @@ -22,7 +22,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "boxes/abstractbox.h" #include "core/observer.h" -#include "core/vector_of_moveable.h" #include "ui/effects/round_checkbox.h" namespace Dialogs { @@ -194,7 +193,7 @@ private: int _upon = -1; ShareBox::FilterCallback _filterCallback; - std_::unique_ptr _chatsIndexed; + std::unique_ptr _chatsIndexed; QString _filter; using FilteredDialogs = QVector; FilteredDialogs _filtered; diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 4e7edcb434..2a22912a55 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -118,16 +118,16 @@ void StickersBox::CounterWidget::updateCounter() { template StickersBox::Tab::Tab(int index, Args&&... args) : _index(index) -, _widget(std_::forward(args)...) +, _widget(std::forward(args)...) , _weak(_widget) { } object_ptr StickersBox::Tab::takeWidget() { - return std_::move(_widget); + return std::move(_widget); } void StickersBox::Tab::returnWidget(object_ptr widget) { - _widget = std_::move(widget); + _widget = std::move(widget); t_assert(_widget == _weak); } @@ -398,7 +398,7 @@ void StickersBox::switchTab() { auto widget = takeInnerWidget(); widget->setParent(this); widget->hide(); - _tab->returnWidget(std_::move(widget)); + _tab->returnWidget(std::move(widget)); _tab = newTab; _section = newSection; setInnerWidget(_tab->takeWidget(), getTopSkip()); @@ -410,8 +410,8 @@ void StickersBox::switchTab() { auto nowCache = grabContentCache(); auto nowIndex = _tab->index(); - _slideAnimation = std_::make_unique(); - _slideAnimation->setSnapshots(std_::move(wasCache), std_::move(nowCache)); + _slideAnimation = std::make_unique(); + _slideAnimation->setSnapshots(std::move(wasCache), std::move(nowCache)); auto slideLeft = wasIndex > nowIndex; _slideAnimation->start(slideLeft, [this] { update(); }, st::slideDuration); setInnerVisible(false); @@ -425,7 +425,7 @@ QPixmap StickersBox::grabContentCache() { _tabs->hide(); auto result = grabInnerCache(); _tabs->show(); - return std_::move(result); + return std::move(result); } void StickersBox::installSet(uint64 setId) { @@ -796,16 +796,16 @@ void StickersBox::Inner::setActionDown(int newActionDown) { if (set->removed) { auto rippleSize = QSize(_undoWidth - st::stickersUndoRemove.width, st::stickersUndoRemove.height); auto rippleMask = Ui::RippleAnimation::roundRectMask(rippleSize, st::buttonRadius); - ensureRipple(st::stickersUndoRemove.ripple, std_::move(rippleMask), removeButton); + ensureRipple(st::stickersUndoRemove.ripple, std::move(rippleMask), removeButton); } else { auto rippleSize = st::stickersRemove.rippleAreaSize; auto rippleMask = Ui::RippleAnimation::ellipseMask(QSize(rippleSize, rippleSize)); - ensureRipple(st::stickersRemove.ripple, std_::move(rippleMask), removeButton); + ensureRipple(st::stickersRemove.ripple, std::move(rippleMask), removeButton); } } else if (!set->installed || set->archived || set->removed) { auto rippleSize = QSize(_addWidth - st::stickersTrendingAdd.width, st::stickersTrendingAdd.height); auto rippleMask = Ui::RippleAnimation::roundRectMask(rippleSize, st::buttonRadius); - ensureRipple(st::stickersTrendingAdd.ripple, std_::move(rippleMask), removeButton); + ensureRipple(st::stickersTrendingAdd.ripple, std::move(rippleMask), removeButton); } } if (set->ripple) { @@ -816,7 +816,7 @@ void StickersBox::Inner::setActionDown(int newActionDown) { } void StickersBox::Inner::ensureRipple(const style::RippleAnimation &st, QImage mask, bool removeButton) { - _rows[_actionDown]->ripple = MakeShared(st, std_::move(mask), [this, index = _actionDown, removeButton] { + _rows[_actionDown]->ripple = MakeShared(st, std::move(mask), [this, index = _actionDown, removeButton] { update(myrtlrect(relativeButtonRect(removeButton).translated(0, _itemsTop + index * _rowHeight))); }); } diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index 75ea838b6a..0dba9fd8b9 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -123,7 +123,7 @@ private: Tab _archived; Tab *_tab = nullptr; - std_::unique_ptr _slideAnimation; + std::unique_ptr _slideAnimation; object_ptr _titleShadow = { nullptr }; int _aboutWidth = 0; @@ -164,10 +164,10 @@ public: void setRemovedSets(const Stickers::Order &removed); void setInstallSetCallback(base::lambda &&callback) { - _installSetCallback = std_::move(callback); + _installSetCallback = std::move(callback); } void setLoadMoreCallback(base::lambda &&callback) { - _loadMoreCallback = std_::move(callback); + _loadMoreCallback = std::move(callback); } void setVisibleTopBottom(int visibleTop, int visibleBottom) override; diff --git a/Telegram/SourceFiles/boxes/stickersetbox.h b/Telegram/SourceFiles/boxes/stickersetbox.h index 7128aae7b7..1ffe642c56 100644 --- a/Telegram/SourceFiles/boxes/stickersetbox.h +++ b/Telegram/SourceFiles/boxes/stickersetbox.h @@ -21,7 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #pragma once #include "boxes/abstractbox.h" -#include "core/vector_of_moveable.h" +#include class ConfirmBox; @@ -111,7 +111,7 @@ private: return (_setFlags & MTPDstickerSet::Flag::f_masks); } - std_::vector_of_moveable _packOvers; + std::vector _packOvers; StickerPack _pack; StickersByEmojiMap _emoji; bool _loaded = false; diff --git a/Telegram/SourceFiles/core/basic_types.h b/Telegram/SourceFiles/core/basic_types.h index 5bf6e0eb51..ae5f87d460 100644 --- a/Telegram/SourceFiles/core/basic_types.h +++ b/Telegram/SourceFiles/core/basic_types.h @@ -22,12 +22,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include +#include #include -#include - #include "core/build_config.h" -#include "core/stl_subset.h" #include "core/ordered_set.h" //using uchar = unsigned char; // Qt has uchar diff --git a/Telegram/SourceFiles/core/click_handler.h b/Telegram/SourceFiles/core/click_handler.h index 4fa398a79b..4ecbf08e8d 100644 --- a/Telegram/SourceFiles/core/click_handler.h +++ b/Telegram/SourceFiles/core/click_handler.h @@ -180,7 +180,7 @@ protected: class LambdaClickHandler : public ClickHandler { public: - LambdaClickHandler(base::lambda &&handler) : _handler(std_::move(handler)) { + LambdaClickHandler(base::lambda &&handler) : _handler(std::move(handler)) { } void onClick(Qt::MouseButton button) const override final { if (button == Qt::LeftButton && _handler) { diff --git a/Telegram/SourceFiles/core/lambda.h b/Telegram/SourceFiles/core/lambda.h index 8fa4f19b20..81674a0061 100644 --- a/Telegram/SourceFiles/core/lambda.h +++ b/Telegram/SourceFiles/core/lambda.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once -#include "core/stl_subset.h" +#include namespace base { namespace internal { @@ -57,7 +57,7 @@ namespace internal { using alignment = uint64; template - using IsLarge = std_::integral_constant) <= kStorageSize)>; + using IsLarge = std::integral_constant) <= kStorageSize)>; protected: static void bad_construct_copy(void *lambda, const void *source) { @@ -95,20 +95,20 @@ namespace internal { template struct lambda_wrap_helper_move_impl; template - struct lambda_wrap_helper_move_impl : public lambda_wrap_helper_base { - using JustLambda = std_::decay_simple_t; - using LambdaPtr = std_::unique_ptr; + struct lambda_wrap_helper_move_impl : public lambda_wrap_helper_base { + using JustLambda = std::decay_t; + using LambdaPtr = std::unique_ptr; using Parent = lambda_wrap_helper_base; static void construct_move_other_method(void *lambda, void *source) { auto source_lambda = static_cast(source); - new (lambda) LambdaPtr(std_::move(*source_lambda)); + new (lambda) LambdaPtr(std::move(*source_lambda)); } static void construct_move_lambda_method(void *lambda, void *source) { auto source_lambda = static_cast(source); - new (lambda) LambdaPtr(std_::make_unique(static_cast(*source_lambda))); + new (lambda) LambdaPtr(std::make_unique(static_cast(*source_lambda))); } static Return call_method(const void *lambda, Args... args) { - return (**static_cast(lambda))(std_::forward(args)...); + return (**static_cast(lambda))(std::forward(args)...); } static void destruct_method(const void *lambda) { static_cast(lambda)->~LambdaPtr(); @@ -133,8 +133,8 @@ namespace internal { }; template - struct lambda_wrap_helper_move_impl : public lambda_wrap_helper_base { - using JustLambda = std_::decay_simple_t; + struct lambda_wrap_helper_move_impl : public lambda_wrap_helper_base { + using JustLambda = std::decay_t; using Parent = lambda_wrap_helper_base; static void construct_move_other_method(void *lambda, void *source) { auto source_lambda = static_cast(source); @@ -143,13 +143,13 @@ namespace internal { static void construct_move_lambda_method(void *lambda, void *source) { static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment."); auto space = sizeof(JustLambda); - auto aligned = std_::align(alignof(JustLambda), space, lambda, space); + auto aligned = std::align(alignof(JustLambda), space, lambda, space); t_assert(aligned == lambda); auto source_lambda = static_cast(source); new (lambda) JustLambda(static_cast(*source_lambda)); } static Return call_method(const void *lambda, Args... args) { - return (*static_cast(lambda))(std_::forward(args)...); + return (*static_cast(lambda))(std::forward(args)...); } static void destruct_method(const void *lambda) { static_cast(lambda)->~JustLambda(); @@ -186,17 +186,17 @@ namespace internal { template struct lambda_wrap_helper_copy_impl; template - struct lambda_wrap_helper_copy_impl : public lambda_wrap_helper_move_impl { - using JustLambda = std_::decay_simple_t; - using LambdaPtr = std_::unique_ptr; - using Parent = lambda_wrap_helper_move_impl; + struct lambda_wrap_helper_copy_impl : public lambda_wrap_helper_move_impl { + using JustLambda = std::decay_t; + using LambdaPtr = std::unique_ptr; + using Parent = lambda_wrap_helper_move_impl; static void construct_copy_other_method(void *lambda, const void *source) { auto source_lambda = static_cast(source); - new (lambda) LambdaPtr(std_::make_unique(*source_lambda->get())); + new (lambda) LambdaPtr(std::make_unique(*source_lambda->get())); } static void construct_copy_lambda_method(void *lambda, const void *source) { auto source_lambda = static_cast(source); - new (lambda) LambdaPtr(std_::make_unique(static_cast(*source_lambda))); + new (lambda) LambdaPtr(std::make_unique(static_cast(*source_lambda))); } lambda_wrap_helper_copy_impl() : Parent(&lambda_wrap_helper_copy_impl::construct_copy_other_method) { } @@ -204,9 +204,9 @@ namespace internal { }; template - struct lambda_wrap_helper_copy_impl : public lambda_wrap_helper_move_impl { - using JustLambda = std_::decay_simple_t; - using Parent = lambda_wrap_helper_move_impl; + struct lambda_wrap_helper_copy_impl : public lambda_wrap_helper_move_impl { + using JustLambda = std::decay_t; + using Parent = lambda_wrap_helper_move_impl; static void construct_copy_other_method(void *lambda, const void *source) { auto source_lambda = static_cast(source); new (lambda) JustLambda(static_cast(*source_lambda)); @@ -214,7 +214,7 @@ namespace internal { static void construct_copy_lambda_method(void *lambda, const void *source) { static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment."); auto space = sizeof(JustLambda); - auto aligned = std_::align(alignof(JustLambda), space, lambda, space); + auto aligned = std::align(alignof(JustLambda), space, lambda, space); t_assert(aligned == lambda); auto source_lambda = static_cast(source); new (lambda) JustLambda(static_cast(*source_lambda)); @@ -245,13 +245,13 @@ class lambda { using EmptyHelper = internal::lambda_wrap_empty; template - using IsUnique = std_::is_same>; + using IsUnique = std::is_same>; template - using IsWrap = std_::is_same, std_::decay_simple_t>; + using IsWrap = std::is_same, std::decay_t>; template - using IsOther = std_::enable_if_t::value && !IsWrap::value>; + using IsOther = std::enable_if_t::value && !IsWrap::value>; template - using IsRvalue = std_::enable_if_t::value>; + using IsRvalue = std::enable_if_t::value>; public: using return_type = Return; @@ -266,7 +266,7 @@ public: helper_->construct_move_other(storage_, other.storage_); } lambda &operator=(lambda &&other) { - auto temp = std_::move(other); + auto temp = std::move(other); helper_->destruct(storage_); helper_ = temp.helper_; helper_->construct_move_other(storage_, temp.storage_); @@ -274,7 +274,7 @@ public: } void swap(lambda &other) { - if (this != &other) std_::swap_moveable(*this, other); + if (this != &other) std::swap(*this, other); } template , typename = IsRvalue> @@ -284,7 +284,7 @@ public: template , typename = IsRvalue> lambda &operator=(Lambda &&other) { - auto temp = std_::move(other); + auto temp = std::move(other); helper_->destruct(storage_); helper_ = &internal::lambda_wrap_helper_move::instance; internal::lambda_wrap_helper_move::construct_move_lambda_method(storage_, &temp); @@ -292,7 +292,7 @@ public: } inline Return operator()(Args... args) const { - return helper_->call(storage_, std_::forward(args)...); + return helper_->call(storage_, std::forward(args)...); } explicit operator bool() const { @@ -322,11 +322,11 @@ class lambda_copy : public lambda { using Parent = lambda; template - using IsOther = std_::enable_if_t>::value>; + using IsOther = std::enable_if_t>::value>; template - using IsRvalue = std_::enable_if_t::value>; + using IsRvalue = std::enable_if_t::value>; template - using IsNotRvalue = std_::enable_if_t::value>; + using IsNotRvalue = std::enable_if_t::value>; public: lambda_copy() = default; @@ -344,7 +344,7 @@ public: lambda_copy &operator=(lambda_copy &&other) = default; void swap(lambda_copy &other) { - if (this != &other) std_::swap_moveable(*this, other); + if (this != &other) std::swap(*this, other); } lambda_copy clone() const { @@ -372,7 +372,7 @@ public: template , typename = IsRvalue> lambda_copy &operator=(Lambda &&other) { - auto temp = std_::move(other); + auto temp = std::move(other); this->helper_->destruct(this->storage_); this->helper_ = &internal::lambda_wrap_helper_copy::instance; internal::lambda_wrap_helper_copy::construct_move_lambda_method(this->storage_, &other); @@ -423,7 +423,7 @@ public: using return_type = typename lambda_type::return_type; template - inline lambda_guard_data(PointersAndLambda&&... qobjectsAndLambda) : _lambda(init(_pointers, std_::forward(qobjectsAndLambda)...)) { + inline lambda_guard_data(PointersAndLambda&&... qobjectsAndLambda) : _lambda(init(_pointers, std::forward(qobjectsAndLambda)...)) { } inline lambda_guard_data(const lambda_guard_data &other) : _lambda(other._lambda) { @@ -439,17 +439,17 @@ public: return return_type(); } } - return _lambda(std_::forward(args)...); + return _lambda(std::forward(args)...); } private: template Lambda init(QPointer *pointers, QObject *qobject, PointersAndLambda&&... qobjectsAndLambda) { *pointers = qobject; - return init(++pointers, std_::forward(qobjectsAndLambda)...); + return init(++pointers, std::forward(qobjectsAndLambda)...); } Lambda init(QPointer *pointers, Lambda &&lambda) { - return std_::move(lambda); + return std::move(lambda); } QPointer _pointers[N]; @@ -463,29 +463,29 @@ public: using return_type = typename lambda_type::return_type; template - inline lambda_guard(PointersAndLambda&&... qobjectsAndLambda) : _data(std_::make_unique>(std_::forward(qobjectsAndLambda)...)) { + inline lambda_guard(PointersAndLambda&&... qobjectsAndLambda) : _data(std::make_unique>(std::forward(qobjectsAndLambda)...)) { static_assert(sizeof...(PointersAndLambda) == N + 1, "Wrong argument count!"); } - inline lambda_guard(const lambda_guard &&other) : _data(std_::move(other._data)) { + inline lambda_guard(const lambda_guard &&other) : _data(std::move(other._data)) { } - inline lambda_guard(lambda_guard &&other) : _data(std_::move(other._data)) { + inline lambda_guard(lambda_guard &&other) : _data(std::move(other._data)) { } inline lambda_guard &operator=(const lambda_guard &&other) { - _data = std_::move(other._data); + _data = std::move(other._data); return *this; } inline lambda_guard &operator=(lambda_guard &&other) { - _data = std_::move(other._data); + _data = std::move(other._data); return *this; } template inline return_type operator()(Args&&... args) const { - return (*_data)(std_::forward(args)...); + return (*_data)(std::forward(args)...); } bool isNull() const { @@ -497,10 +497,10 @@ public: } private: - inline lambda_guard(const lambda_guard &other) : _data(std_::make_unique>(static_cast &>(*other._data))) { + inline lambda_guard(const lambda_guard &other) : _data(std::make_unique>(static_cast &>(*other._data))) { } - mutable std_::unique_ptr> _data; + mutable std::unique_ptr> _data; }; @@ -536,7 +536,7 @@ struct lambda_type_helper> { template inline internal::lambda_guard_t lambda_guarded(PointersAndLambda&&... qobjectsAndLambda) { static_assert(sizeof...(PointersAndLambda) > 0, "Lambda should be passed here."); - return internal::lambda_guard_t(std_::forward(qobjectsAndLambda)...); + return internal::lambda_guard_t(std::forward(qobjectsAndLambda)...); } // Pass lambda instead of a Qt void() slot. @@ -545,7 +545,7 @@ class lambda_slot_wrap : public QObject { Q_OBJECT public: - lambda_slot_wrap(QObject *parent, lambda &&lambda) : QObject(parent), _lambda(std_::move(lambda)) { + lambda_slot_wrap(QObject *parent, lambda &&lambda) : QObject(parent), _lambda(std::move(lambda)) { } public slots: @@ -559,14 +559,14 @@ private: }; inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda &&lambda) { - return new lambda_slot_wrap(parent, std_::move(lambda)); + return new lambda_slot_wrap(parent, std::move(lambda)); } class lambda_slot_once_wrap : public QObject { Q_OBJECT public: - lambda_slot_once_wrap(QObject *parent, lambda &&lambda) : QObject(parent), _lambda(std_::move(lambda)) { + lambda_slot_once_wrap(QObject *parent, lambda &&lambda) : QObject(parent), _lambda(std::move(lambda)) { } public slots : @@ -581,7 +581,7 @@ private: }; inline lambda_slot_once_wrap *lambda_slot_once(QObject *parent, lambda &&lambda) { - return new lambda_slot_once_wrap(parent, std_::move(lambda)); + return new lambda_slot_once_wrap(parent, std::move(lambda)); } } // namespace base diff --git a/Telegram/SourceFiles/core/observer.h b/Telegram/SourceFiles/core/observer.h index 8278baa158..f5a9d3fed2 100644 --- a/Telegram/SourceFiles/core/observer.h +++ b/Telegram/SourceFiles/core/observer.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once -#include "core/vector_of_moveable.h" +#include #include "core/type_traits.h" namespace base { @@ -117,7 +117,7 @@ public: if (!_data) { _data = MakeShared>(this); } - return _data->append(std_::move(handler)); + return _data->append(std::move(handler)); } private: @@ -133,7 +133,7 @@ class BaseObservable : public internal::CommonObservab public: void notify(EventType event, bool sync = false) { if (this->_data) { - this->_data->notify(std_::move(event), sync); + this->_data->notify(std::move(event), sync); } } @@ -144,7 +144,7 @@ class BaseObservable : public internal::CommonObserva public: void notify(EventType &&event, bool sync = false) { if (this->_data) { - this->_data->notify(std_::move(event), sync); + this->_data->notify(std::move(event), sync); } } void notify(const EventType &event, bool sync = false) { @@ -166,7 +166,7 @@ public: } Subscription append(Handler &&handler) { - auto node = new Node(_observable->_data, std_::move(handler)); + auto node = new Node(_observable->_data, std::move(handler)); if (_begin) { _end->next = node; node->prev = _end; @@ -183,7 +183,7 @@ public: private: struct Node : public Subscription::Node { - Node(const QSharedPointer &observer, Handler &&handler) : Subscription::Node(observer), handler(std_::move(handler)) { + Node(const QSharedPointer &observer, Handler &&handler) : Subscription::Node(observer), handler(std::move(handler)) { } Handler handler; }; @@ -253,7 +253,7 @@ public: sync = false; } if (sync) { - _events.push_back(std_::move(event)); + _events.push_back(std::move(event)); callHandlers(); } else { if (!this->_callHandlers) { @@ -264,7 +264,7 @@ public: if (_events.empty()) { RegisterPendingObservable(&this->_callHandlers); } - _events.push_back(std_::move(event)); + _events.push_back(std::move(event)); } } @@ -285,7 +285,7 @@ private: UnregisterActiveObservable(&this->_callHandlers); } - std_::vector_of_moveable _events; + std::vector _events; bool _handling = false; }; @@ -404,23 +404,23 @@ class Subscriber { protected: template int subscribe(base::Observable &observable, Lambda &&handler) { - _subscriptions.push_back(observable.add_subscription(std_::forward(handler))); + _subscriptions.push_back(observable.add_subscription(std::forward(handler))); return _subscriptions.size(); } template int subscribe(base::Observable *observable, Lambda &&handler) { - return subscribe(*observable, std_::forward(handler)); + return subscribe(*observable, std::forward(handler)); } template int subscribe(base::Variable &variable, Lambda &&handler) { - return subscribe(variable.observable(), std_::forward(handler)); + return subscribe(variable.observable(), std::forward(handler)); } template int subscribe(base::Variable *variable, Lambda &&handler) { - return subscribe(variable->observable(), std_::forward(handler)); + return subscribe(variable->observable(), std::forward(handler)); } void unsubscribe(int index) { @@ -442,7 +442,7 @@ protected: } private: - std_::vector_of_moveable _subscriptions; + std::vector _subscriptions; }; diff --git a/Telegram/SourceFiles/core/qthelp_regex.h b/Telegram/SourceFiles/core/qthelp_regex.h index 1a29fe9eea..ceb0d3b633 100644 --- a/Telegram/SourceFiles/core/qthelp_regex.h +++ b/Telegram/SourceFiles/core/qthelp_regex.h @@ -24,16 +24,16 @@ namespace qthelp { class RegularExpressionMatch { public: - RegularExpressionMatch(QRegularExpressionMatch &&match) : data_(std_::move(match)) { + RegularExpressionMatch(QRegularExpressionMatch &&match) : data_(std::move(match)) { } - RegularExpressionMatch(RegularExpressionMatch &&other) : data_(std_::move(other.data_)) { + RegularExpressionMatch(RegularExpressionMatch &&other) : data_(std::move(other.data_)) { } RegularExpressionMatch &operator=(QRegularExpressionMatch &&match) { - data_ = std_::move(match); + data_ = std::move(match); return *this; } RegularExpressionMatch &operator=(RegularExpressionMatch &&other) { - data_ = std_::move(other.data_); + data_ = std::move(other.data_); return *this; } QRegularExpressionMatch *operator->() { diff --git a/Telegram/SourceFiles/core/runtime_composer.h b/Telegram/SourceFiles/core/runtime_composer.h index 038f5712cd..febf011ad0 100644 --- a/Telegram/SourceFiles/core/runtime_composer.h +++ b/Telegram/SourceFiles/core/runtime_composer.h @@ -97,7 +97,7 @@ protected: ((Type*)location)->~Type(); } static void RuntimeComponentMove(void *location, void *waslocation) { - *(Type*)location = std_::move(*(Type*)waslocation); + *(Type*)location = std::move(*(Type*)waslocation); } }; @@ -164,7 +164,7 @@ public: try { auto constructAt = _dataptrunsafe(offset); auto space = RuntimeComponentWraps[i].Size; - auto alignedAt = std_::align(RuntimeComponentWraps[i].Align, space, constructAt, space); + auto alignedAt = std::align(RuntimeComponentWraps[i].Align, space, constructAt, space); t_assert(alignedAt == constructAt); RuntimeComponentWraps[i].Construct(constructAt, this); } catch (...) { diff --git a/Telegram/SourceFiles/core/single_timer.cpp b/Telegram/SourceFiles/core/single_timer.cpp index f9ce4445a1..fed0ba4ade 100644 --- a/Telegram/SourceFiles/core/single_timer.cpp +++ b/Telegram/SourceFiles/core/single_timer.cpp @@ -37,7 +37,7 @@ void SingleTimer::setTimeoutHandler(base::lambda &&handler) { } else if (handler && !_handler) { connect(this, SIGNAL(timeout()), this, SLOT(onTimeout())); } - _handler = std_::move(handler); + _handler = std::move(handler); } void SingleTimer::adjust() { diff --git a/Telegram/SourceFiles/core/stl_subset.h b/Telegram/SourceFiles/core/stl_subset.h deleted file mode 100644 index bfecd2909c..0000000000 --- a/Telegram/SourceFiles/core/stl_subset.h +++ /dev/null @@ -1,297 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -In addition, as a special exception, the copyright holders give permission -to link the code of portions of this program with the OpenSSL library. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -*/ -#pragma once - -#include - -// we copy some parts of C++11/14/17 std:: library, because on OS X 10.6+ -// version we can use C++11/14/17, but we can not use its library :( -namespace std_ { - -using nullptr_t = decltype(nullptr); - -template -struct integral_constant { - static constexpr T value = V; - - using value_type = T; - using type = integral_constant; - - constexpr operator value_type() const noexcept { - return (value); - } - - constexpr value_type operator()() const noexcept { - return (value); - } -}; - -using true_type = integral_constant; -using false_type = integral_constant; - -template -struct remove_reference { - using type = T; -}; -template -struct remove_reference { - using type = T; -}; -template -struct remove_reference { - using type = T; -}; -template -using remove_reference_t = typename remove_reference::type; - -template -struct is_lvalue_reference : false_type { -}; -template -struct is_lvalue_reference : true_type { -}; - -template -struct is_rvalue_reference : false_type { -}; -template -struct is_rvalue_reference : true_type { -}; - -template -inline constexpr T &&forward(typename remove_reference::type &value) noexcept { - return static_cast(value); -} -template -inline constexpr T &&forward(typename remove_reference::type &&value) noexcept { - static_assert(!is_lvalue_reference::value, "bad forward call"); - return static_cast(value); -} - -template -inline constexpr typename remove_reference::type &&move(T &&value) noexcept { - return static_cast::type&&>(value); -} - -template -void swap_moveable(T &a, T &b) { - T tmp = move(a); - a = move(b); - b = move(tmp); -} - -template -struct remove_const { - using type = T; -}; - -template -struct remove_const { - using type = T; -}; - -template -struct remove_volatile { - using type = T; -}; - -template -struct remove_volatile { - using type = T; -}; - -template -using decay_simple_t = typename remove_const::type>::type>::type; - -template -struct is_same : false_type { -}; - -template -struct is_same : true_type { -}; - -template -struct enable_if { -}; - -template -struct enable_if { - using type = T; -}; - -template -using enable_if_t = typename enable_if::type; - -template -struct conditional { - using type = Second; -}; - -template -struct conditional { - using type = First; -}; - -template -using conditional_t = typename conditional::type; - -template -struct add_const { - using type = const T; -}; - -template -using add_const_t = typename add_const::type; - -// This is not full unique_ptr, but at least with std interface. -template -class unique_ptr { -public: - constexpr unique_ptr() noexcept = default; - unique_ptr(const unique_ptr &) = delete; - unique_ptr &operator=(const unique_ptr &) = delete; - - constexpr unique_ptr(std_::nullptr_t) { - } - unique_ptr &operator=(std_::nullptr_t) noexcept { - reset(); - return (*this); - } - - explicit unique_ptr(T *p) noexcept : _p(p) { - } - - template - unique_ptr(unique_ptr &&other) noexcept : _p(other.release()) { - } - template - unique_ptr &operator=(unique_ptr &&other) noexcept { - reset(other.release()); - return (*this); - } - unique_ptr &operator=(unique_ptr &&other) noexcept { - if (this != &other) { - reset(other.release()); - } - return (*this); - } - - void swap(unique_ptr &other) noexcept { - std::swap(_p, other._p); - } - ~unique_ptr() noexcept { - if (_p) { - static_assert(sizeof(T) > 0, "can't delete an incomplete type"); - delete _p; - _p = nullptr; - } - } - - T &operator*() const { - return (*get()); - } - T *operator->() const noexcept { - return get(); - } - T *get() const noexcept { - return _p; - } - explicit operator bool() const noexcept { - return get() != nullptr; - } - - T *release() noexcept { - auto old = _p; - _p = nullptr; - return old; - } - - void reset(T *p = nullptr) noexcept { - auto old = _p; - _p = p; - if (old) { - static_assert(sizeof(T) > 0, "can't delete an incomplete type"); - delete old; - } - } - -private: - T *_p = nullptr; - -}; - -template -inline unique_ptr make_unique(Args&&... args) { - return unique_ptr(new T(forward(args)...)); -} - -template -inline bool operator==(const unique_ptr &a, std_::nullptr_t) noexcept { - return !a; -} -template -inline bool operator==(std_::nullptr_t, const unique_ptr &b) noexcept { - return !b; -} -template -inline bool operator!=(const unique_ptr &a, std_::nullptr_t b) noexcept { - return !(a == b); -} -template -inline bool operator!=(std_::nullptr_t a, const unique_ptr &b) noexcept { - return !(a == b); -} - -using _yes = char(&)[1]; -using _no = char(&)[2]; - -template -struct _host { - operator Base*() const; - operator Derived*(); -}; - -template -struct is_base_of { - template - static _yes check(Derived*, T); - static _no check(Base*, int); - - static constexpr bool value = sizeof(check(_host(), int())) == sizeof(_yes); -}; - -inline void *align(size_t alignment, size_t size, void*& ptr, size_t& space) noexcept { -#ifndef OS_MAC_OLD - using std::uintptr_t; -#endif // OS_MAC_OLD - - auto p = reinterpret_cast(ptr); - auto a = (p - 1u + alignment) & -alignment; - auto d = a - p; - if ((size + d) > space) { - return nullptr; - } - space -= d; - return ptr = reinterpret_cast(a); -} - -} // namespace std_ diff --git a/Telegram/SourceFiles/core/task_queue.cpp b/Telegram/SourceFiles/core/task_queue.cpp index b258ab8bbe..7a1c549743 100644 --- a/Telegram/SourceFiles/core/task_queue.cpp +++ b/Telegram/SourceFiles/core/task_queue.cpp @@ -30,7 +30,7 @@ const auto MaxThreadsCount = qMax(QThread::idealThreadCount(), 2); template class Thread : public QThread { public: - Thread(Lambda code) : _code(std_::move(code)) { + Thread(Lambda code) : _code(std::move(code)) { } void run() override { _code(); @@ -43,7 +43,7 @@ private: template object_ptr> MakeThread(Lambda code) { - return object_ptr>(std_::move(code)); + return object_ptr>(std::move(code)); } } // namespace @@ -88,7 +88,7 @@ private: void ThreadFunction(); - std_::vector_of_moveable> threads_; + std::vector> threads_; QMutex queues_mutex_; // queues_mutex_ must be locked when working with the list. @@ -195,7 +195,7 @@ TaskQueue *TaskQueue::TaskQueueList::TakeFirst(int list_index_) { void TaskQueue::TaskThreadPool::AddQueueTask(TaskQueue *queue, Task &&task) { QMutexLocker lock(&queues_mutex_); - queue->tasks_.push_back(new Task(std_::move(task))); + queue->tasks_.push_back(new Task(std::move(task))); auto list_was_empty = queue_list_.Empty(kAllQueuesList); auto threads_count = threads_.size(); auto all_threads_processing = (threads_count == tasks_in_process_); @@ -258,7 +258,7 @@ void TaskQueue::TaskThreadPool::ThreadFunction() { bool serial_queue_destroyed = false; bool task_was_processed = false; while (true) { - std_::unique_ptr task; + std::unique_ptr task; { QMutexLocker lock(&queues_mutex_); @@ -344,12 +344,12 @@ TaskQueue::~TaskQueue() { void TaskQueue::Put(Task &&task) { if (type_ == Type::Main) { QMutexLocker lock(&tasks_mutex_); - tasks_.push_back(new Task(std_::move(task))); + tasks_.push_back(new Task(std::move(task))); Sandbox::MainThreadTaskAdded(); } else { t_assert(type_ != Type::Special); - TaskThreadPool::Instance()->AddQueueTask(this, std_::move(task)); + TaskThreadPool::Instance()->AddQueueTask(this, std::move(task)); } } @@ -372,7 +372,7 @@ void TaskQueue::ProcessMainTasks(TimeMs max_time_spent) { // static } bool TaskQueue::ProcessOneMainTask() { // static - std_::unique_ptr task; + std::unique_ptr task; { QMutexLocker lock(&Main().tasks_mutex_); auto &tasks = Main().tasks_; diff --git a/Telegram/SourceFiles/core/task_queue.h b/Telegram/SourceFiles/core/task_queue.h index f07e5824b2..0d4c424550 100644 --- a/Telegram/SourceFiles/core/task_queue.h +++ b/Telegram/SourceFiles/core/task_queue.h @@ -69,7 +69,7 @@ private: const Type type_; const Priority priority_; - QList tasks_; // TODO: std_::deque_of_moveable + QList tasks_; // TODO: std::deque QMutex tasks_mutex_; // Only for the main queue. // Only for the other queues, not main. diff --git a/Telegram/SourceFiles/core/type_traits.h b/Telegram/SourceFiles/core/type_traits.h index 3f8f7fc0ea..4979ce656f 100644 --- a/Telegram/SourceFiles/core/type_traits.h +++ b/Telegram/SourceFiles/core/type_traits.h @@ -20,16 +20,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once -#include "core/stl_subset.h" - namespace base { template -struct custom_is_fast_copy_type : public std_::false_type { +struct custom_is_fast_copy_type : public std::false_type { }; // To make your own type a fast copy type just write: // template <> -// struct base::custom_is_fast_copy_type : public std_::true_type { +// struct base::custom_is_fast_copy_type : public std::true_type { // }; namespace internal { @@ -38,11 +36,11 @@ template struct type_list_contains; template -struct type_list_contains : public std_::false_type { +struct type_list_contains : public std::false_type { }; template -struct type_list_contains : public std_::integral_constant::value || type_list_contains::value> { +struct type_list_contains : public std::integral_constant::value || type_list_contains::value> { }; template @@ -52,35 +50,35 @@ template using is_std_signed_int = type_list_contains; template -using is_std_integral = std_::integral_constant::value || is_std_signed_int::value || type_list_contains::value>; +using is_std_integral = std::integral_constant::value || is_std_signed_int::value || type_list_contains::value>; template using is_std_float = type_list_contains; template -using is_std_arith = std_::integral_constant::value || is_std_float::value>; +using is_std_arith = std::integral_constant::value || is_std_float::value>; template -using is_std_fundamental = std_::integral_constant::value || std_::is_same::value>; +using is_std_fundamental = std::integral_constant::value || std::is_same::value>; template -struct is_pointer : public std_::false_type { +struct is_pointer : public std::false_type { }; template -struct is_pointer : public std_::true_type { +struct is_pointer : public std::true_type { }; template -struct is_member_pointer : public std_::false_type { +struct is_member_pointer : public std::false_type { }; template -struct is_member_pointer : public std_::true_type { +struct is_member_pointer : public std::true_type { }; template -using is_fast_copy_type = std_::integral_constant::value || is_pointer::value || is_member_pointer::value || custom_is_fast_copy_type::value>; +using is_fast_copy_type = std::integral_constant::value || is_pointer::value || is_member_pointer::value || custom_is_fast_copy_type::value>; template struct add_const_reference { @@ -122,7 +120,7 @@ struct type_traits { using is_member_pointer = internal::is_member_pointer; using is_fast_copy_type = internal::is_fast_copy_type; - using parameter_type = std_::conditional_t>; + using parameter_type = std::conditional_t>; using pointed_type = internal::remove_pointer_t; }; diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h index cc6d444a50..ce97b7c3ac 100644 --- a/Telegram/SourceFiles/core/utils.h +++ b/Telegram/SourceFiles/core/utils.h @@ -31,40 +31,35 @@ inline constexpr size_t array_size(const T(&)[N]) { template inline T take(T &source, T &&new_value = T()) { - std_::swap_moveable(new_value, source); - return std_::move(new_value); + std::swap(new_value, source); + return std::move(new_value); } namespace internal { template -inline constexpr D up_cast_helper(std_::true_type, T object) { +inline constexpr D up_cast_helper(std::true_type, T object) { return object; } template -inline constexpr D up_cast_helper(std_::false_type, T object) { +inline constexpr D up_cast_helper(std::false_type, T object) { return nullptr; } -template -constexpr std_::add_const_t &any_as_const(T &&value) noexcept { - return value; -} - } // namespace internal template inline constexpr D up_cast(T object) { - using DV = std_::decay_simple_t; - using TV = std_::decay_simple_t; - return internal::up_cast_helper(std_::integral_constant::value || std_::is_same::value>(), object); + using DV = std::decay_t; + using TV = std::decay_t; + return internal::up_cast_helper(std::integral_constant::value || std::is_same::value>(), object); } template class scope_guard_helper { public: - scope_guard_helper(Lambda on_scope_exit) : _handler(std_::move(on_scope_exit)) { + scope_guard_helper(Lambda on_scope_exit) : _handler(std::move(on_scope_exit)) { } void dismiss() { _dismissed = true; @@ -83,7 +78,7 @@ private: template scope_guard_helper scope_guard(Lambda on_scope_exit) { - return scope_guard_helper(std_::move(on_scope_exit)); + return scope_guard_helper(std::move(on_scope_exit)); } } // namespace base @@ -92,7 +87,7 @@ scope_guard_helper scope_guard(Lambda on_scope_exit) { // it is important for the copy-on-write Qt containers // if you have "QVector v" then "for (T * const p : v)" will still call QVector::detach(), // while "for_const (T *p, v)" won't and "for_const (T *&p, v)" won't compile -#define for_const(range_declaration, range_expression) for (range_declaration : base::internal::any_as_const(range_expression)) +#define for_const(range_declaration, range_expression) for (range_declaration : std::as_const(range_expression)) template inline QFlags qFlags(Enum v) { @@ -497,7 +492,7 @@ static int32 AlmostFullArcLength = (FullArcLength - MinArcLength); template inline QSharedPointer MakeShared(Args&&... args) { - return QSharedPointer(new T(std_::forward(args)...)); + return QSharedPointer(new T(std::forward(args)...)); } // This pointer is used for global non-POD variables that are allocated @@ -512,7 +507,7 @@ public: template void createIfNull(Args&&... args) { if (isNull()) { - reset(new T(std_::forward(args)...)); + reset(new T(std::forward(args)...)); } }; diff --git a/Telegram/SourceFiles/core/vector_of_moveable.h b/Telegram/SourceFiles/core/vector_of_moveable.h deleted file mode 100644 index b2f156b452..0000000000 --- a/Telegram/SourceFiles/core/vector_of_moveable.h +++ /dev/null @@ -1,184 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -In addition, as a special exception, the copyright holders give permission -to link the code of portions of this program with the OpenSSL library. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -*/ -#pragma once - -#include "core/stl_subset.h" - -// some minimal implementation of std::vector() for moveable (but not copiable) types. -namespace std_ { - -template -class vector_of_moveable { - typedef vector_of_moveable Self; - int _size = 0, _capacity = 0; - void *_plaindata = nullptr; - -public: - vector_of_moveable() = default; - vector_of_moveable(const vector_of_moveable &other) = delete; - vector_of_moveable &operator=(const vector_of_moveable &other) = delete; - vector_of_moveable(vector_of_moveable &&other) - : _size(base::take(other._size)) - , _capacity(base::take(other._capacity)) - , _plaindata(base::take(other._plaindata)) { - } - vector_of_moveable &operator=(vector_of_moveable &&other) { - std_::swap_moveable(_size, other._size); - std_::swap_moveable(_capacity, other._capacity); - std_::swap_moveable(_plaindata, other._plaindata); - return *this; - } - - inline T *data() { - return reinterpret_cast(_plaindata); - } - inline const T *data() const { - return reinterpret_cast(_plaindata); - } - - inline bool operator==(const Self &other) const { - if (this == &other) return true; - if (_size != other._size) return false; - for (int i = 0; i < _size; ++i) { - if (data()[i] != other.data()[i]) { - return false; - } - } - return true; - } - inline bool operator!=(const Self &other) const { return !(*this == other); } - inline int size() const { return _size; } - inline bool isEmpty() const { return _size == 0; } - inline void clear() { - for (int i = 0; i < _size; ++i) { - data()[i].~T(); - } - _size = 0; - - operator delete[](_plaindata); - _plaindata = nullptr; - _capacity = 0; - } - - typedef T *iterator; - typedef const T *const_iterator; - - // STL style - inline iterator begin() { return data(); } - inline const_iterator begin() const { return data(); } - inline const_iterator cbegin() const { return data(); } - inline iterator end() { return data() + _size; } - inline const_iterator end() const { return data() + _size; } - inline const_iterator cend() const { return data() + _size; } - inline iterator erase(iterator it) { - T tmp = std_::move(*it); - for (auto next = it + 1, e = end(); next != e; ++next) { - auto prev = next - 1; - *prev = std_::move(*next); - } - --_size; - end()->~T(); - return it; - } - - inline iterator insert(const_iterator pos, T &&value) { - int insertAtIndex = pos - begin(); - if (_size + 1 > _capacity) { - reallocate(_capacity + (_capacity > 1 ? _capacity / 2 : 1)); - } - auto insertAt = begin() + insertAtIndex, e = end(); - if (insertAt == e) { - new (&(*insertAt)) T(std_::move(value)); - } else { - auto prev = e - 1; - new (&(*e)) T(std_::move(*prev)); - for (auto it = prev; it != insertAt; --it) { - *it = std_::move(*--prev); - } - *insertAt = std_::move(value); - } - ++_size; - return insertAt; - } - inline void push_back(T &&value) { - insert(end(), std_::move(value)); - } - inline void pop_back() { - erase(end() - 1); - } - inline T &front() { - return *begin(); - } - inline const T &front() const { - return *begin(); - } - inline T &back() { - return *(end() - 1); - } - inline const T &back() const { - return *(end() - 1); - } - inline bool empty() const { return _size == 0; } - - inline T &operator[](int index) { - return data()[index]; - } - inline const T &operator[](int index) const { - return data()[index]; - } - inline const T &at(int index) const { - if (index < 0 || index >= _size) { -#ifndef OS_MAC_OLD - throw std::out_of_range(""); -#else // OS_MAC_OLD - throw std::exception(); -#endif // OS_MAC_OLD - } - return data()[index]; - } - - void reserve(int newCapacity) { - if (newCapacity > _capacity) { - reallocate(newCapacity); - } - } - - inline ~vector_of_moveable() { - clear(); - } - -private: - void reallocate(int newCapacity) { - auto newPlainData = operator new[](newCapacity * sizeof(T)); - for (int i = 0; i < _size; ++i) { - auto oldLocation = data() + i; - auto newLocation = reinterpret_cast(newPlainData) + i; - new (newLocation) T(std_::move(*oldLocation)); - oldLocation->~T(); - } - std_::swap_moveable(_plaindata, newPlainData); - _capacity = newCapacity; - operator delete[](newPlainData); - } - -}; - -} // namespace std_ diff --git a/Telegram/SourceFiles/core/virtual_method.h b/Telegram/SourceFiles/core/virtual_method.h index 38e70598ec..fd85bed88c 100644 --- a/Telegram/SourceFiles/core/virtual_method.h +++ b/Telegram/SourceFiles/core/virtual_method.h @@ -233,9 +233,9 @@ typename virtual_object::virtual_object_registrator virtual_object namespace virtual_methods { template -struct is_virtual_argument : public std_::integral_constant::is_pointer::value - ? std_::is_base_of::pointed_type>::value + ? std::is_base_of::pointed_type>::value : false> { }; @@ -281,10 +281,10 @@ struct multi_index_collector { multi_index_collector::call(indices.subindex(), args...); } - static inline int computeIndex(std_::integral_constant, ConcreteArg arg) { + static inline int computeIndex(std::integral_constant, ConcreteArg arg) { return 0; } - static inline int computeIndex(std_::integral_constant, ConcreteArg arg) { + static inline int computeIndex(std::integral_constant, ConcreteArg arg) { return arg->virtual_object_child_index(); } @@ -348,15 +348,15 @@ public: return (*this)[index.current()][index.subindex()]; } inline int size() const { - return count_size(std_::integral_constant()); + return count_size(std::integral_constant()); } private: template - inline int count_size(std_::integral_constant) const { + inline int count_size(std::integral_constant) const { return _size.current() / _size.subindex().current(); } - inline int count_size(std_::integral_constant) const { + inline int count_size(std::integral_constant) const { return _size.current(); } @@ -391,10 +391,10 @@ struct table_count_size { index.current() = count(is_virtual_argument()) * subindex.current(); } - static inline int count(std_::integral_constant) { + static inline int count(std::integral_constant) { return 1; } - static inline int count(std_::integral_constant) { + static inline int count(std::integral_constant) { return base::type_traits::pointed_type::virtual_object_get_child_entries().size(); } @@ -483,10 +483,10 @@ struct table_fill_entry_helper { return false; } - static inline bool good(std_::integral_constant, int start, int current) { + static inline bool good(std::integral_constant, int start, int current) { return (start == current); } - static inline bool good(std_::integral_constant, int start, int current) { + static inline bool good(std::integral_constant, int start, int current) { using BaseObject = typename base::type_traits::pointed_type; auto &entries = BaseObject::virtual_object_get_child_entries(); return (start == current) || entries[start].check_is_parent(entries[current]); @@ -531,10 +531,10 @@ struct override_key_collector_helper { override_key_collector_helper::call(indices); } - static inline void setValue(std_::integral_constant, int **indices) { + static inline void setValue(std::integral_constant, int **indices) { indices[M] = nullptr; } - static inline void setValue(std_::integral_constant, int **indices) { + static inline void setValue(std::integral_constant, int **indices) { using ConcreteObject = typename base::type_traits::pointed_type; using IsParentCheckStruct = is_parent; using IsParentCheckPointer = decltype(&IsParentCheckStruct::check); diff --git a/Telegram/SourceFiles/data/data_drafts.cpp b/Telegram/SourceFiles/data/data_drafts.cpp index 5000a976a1..c5e0604093 100644 --- a/Telegram/SourceFiles/data/data_drafts.cpp +++ b/Telegram/SourceFiles/data/data_drafts.cpp @@ -44,10 +44,10 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) { auto entities = draft.has_entities() ? entitiesFromMTP(draft.ventities.c_vector().v) : EntitiesInText(); TextWithTags textWithTags = { textApplyEntities(text, entities), textTagsFromEntities(entities) }; MsgId replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : 0; - auto cloudDraft = std_::make_unique(textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage()); + auto cloudDraft = std::make_unique(textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage()); cloudDraft->date = ::date(draft.vdate); - history->setCloudDraft(std_::move(cloudDraft)); + history->setCloudDraft(std::move(cloudDraft)); history->createLocalDraftFromCloud(); history->updateChatListSortPosition(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_list.cpp b/Telegram/SourceFiles/dialogs/dialogs_list.cpp index 1e80c121b0..9907c52b71 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_list.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_list.cpp @@ -28,7 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Dialogs { List::List(SortMode sortMode) -: _last(std_::make_unique(nullptr, nullptr, nullptr, 0)) +: _last(std::make_unique(nullptr, nullptr, nullptr, 0)) , _begin(_last.get()) , _end(_last.get()) , _sortMode(sortMode) diff --git a/Telegram/SourceFiles/dialogs/dialogs_list.h b/Telegram/SourceFiles/dialogs/dialogs_list.h index bd5e4adc94..ccf4e1a557 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_list.h +++ b/Telegram/SourceFiles/dialogs/dialogs_list.h @@ -121,7 +121,7 @@ private: return row->_prev; } - std_::unique_ptr _last; + std::unique_ptr _last; Row *_begin; Row *_end; SortMode _sortMode; diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index d2d901f7ca..08db611ca1 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -33,7 +33,7 @@ RippleRow::~RippleRow() = default; void RippleRow::addRipple(QPoint origin, QSize size, base::lambda_copy &&updateCallback) { if (!_ripple) { auto mask = Ui::RippleAnimation::rectMask(size); - _ripple = std_::make_unique(st::dialogsRipple, std_::move(mask), std_::move(updateCallback)); + _ripple = std::make_unique(st::dialogsRipple, std::move(mask), std::move(updateCallback)); } _ripple->add(origin); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.h b/Telegram/SourceFiles/dialogs/dialogs_row.h index 14f61482b1..187f9101ed 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.h +++ b/Telegram/SourceFiles/dialogs/dialogs_row.h @@ -45,7 +45,7 @@ public: void paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride = nullptr) const; private: - mutable std_::unique_ptr _ripple; + mutable std::unique_ptr _ripple; }; diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 575126dcca..94d71fa02e 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -72,9 +72,9 @@ struct DialogsInner::PeerSearchResult { }; DialogsInner::DialogsInner(QWidget *parent, QWidget *main) : SplittedWidget(parent) -, _dialogs(std_::make_unique(Dialogs::SortMode::Date)) -, _contactsNoDialogs(std_::make_unique(Dialogs::SortMode::Name)) -, _contacts(std_::make_unique(Dialogs::SortMode::Name)) +, _dialogs(std::make_unique(Dialogs::SortMode::Date)) +, _contactsNoDialogs(std::make_unique(Dialogs::SortMode::Name)) +, _contacts(std::make_unique(Dialogs::SortMode::Name)) , _a_pinnedShifting(animation(this, &DialogsInner::step_pinnedShifting)) , _addContactLnk(this, lang(lng_add_contact_button)) , _cancelSearchInPeer(this, st::dialogsCancelSearchInPeer) { @@ -85,8 +85,8 @@ DialogsInner::DialogsInner(QWidget *parent, QWidget *main) : SplittedWidget(pare #endif // OS_MAC_OLD if (Global::DialogsModeEnabled()) { - _dialogsImportant = std_::make_unique(Dialogs::SortMode::Date); - _importantSwitch = std_::make_unique(); + _dialogsImportant = std::make_unique(Dialogs::SortMode::Date); + _importantSwitch = std::make_unique(); } connect(main, SIGNAL(peerNameChanged(PeerData*, const PeerData::Names&, const PeerData::NameFirstChars&)), this, SLOT(onPeerNameChanged(PeerData*, const PeerData::Names&, const PeerData::NameFirstChars&))); connect(main, SIGNAL(peerPhotoChanged(PeerData*)), this, SLOT(onPeerPhotoChanged(PeerData*))); @@ -130,7 +130,7 @@ int DialogsInner::peerSearchOffset() const { } int DialogsInner::searchedOffset() const { - int result = peerSearchOffset() + (_peerSearchResults.isEmpty() ? 0 : ((_peerSearchResults.size() * st::dialogsRowHeight) + st::searchedBarHeight)); + int result = peerSearchOffset() + (_peerSearchResults.empty() ? 0 : ((_peerSearchResults.size() * st::dialogsRowHeight) + st::searchedBarHeight)); if (_searchInPeer) result += st::dialogsRowHeight; return result; } @@ -162,7 +162,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO auto active = App::main()->activePeer(); auto selected = _menuPeer ? _menuPeer : (isPressed() ? (_pressed ? _pressed->history()->peer : nullptr) : (_selected ? _selected->history()->peer : nullptr)); if (otherStart) { - auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.isEmpty()); + auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.empty()); auto &list = rows->all(); if (reorderingPinned) { dialogsClip = dialogsClip.marginsAdded(QMargins(0, st::dialogsRowHeight, 0, st::dialogsRowHeight)); @@ -214,7 +214,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO } } } else if (_state == FilteredState || _state == SearchedState) { - if (!_hashtagResults.isEmpty()) { + if (!_hashtagResults.empty()) { int32 from = floorclamp(r.y(), st::mentionHeight, 0, _hashtagResults.size()); int32 to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size()); p.translate(0, from * st::mentionHeight); @@ -279,7 +279,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO } } - if (!_peerSearchResults.isEmpty()) { + if (!_peerSearchResults.empty()) { p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg); if (!paintingOther) { p.setFont(st::searchedBarFont); @@ -309,7 +309,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO if (_searchInPeer) { paintSearchInPeer(p, fullWidth, paintingOther); p.translate(0, st::dialogsRowHeight); - if (_state == FilteredState && _searchResults.isEmpty()) { + if (_state == FilteredState && _searchResults.empty()) { p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg); if (!paintingOther) { p.setFont(st::searchedBarFont); @@ -320,8 +320,8 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO } } - if (_state == SearchedState || !_searchResults.isEmpty()) { - QString text = lng_search_found_results(lt_count, _searchResults.isEmpty() ? 0 : (_searchedMigratedCount + _searchedCount)); + if (_state == SearchedState || !_searchResults.empty()) { + QString text = lng_search_found_results(lt_count, _searchResults.empty() ? 0 : (_searchedMigratedCount + _searchedCount)); p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg); if (!paintingOther) { p.setFont(st::searchedBarFont); @@ -491,7 +491,7 @@ void DialogsInner::updateSelected(QPoint localPos) { } } else if (_state == FilteredState || _state == SearchedState) { auto wasSelected = isSelected(); - if (_hashtagResults.isEmpty()) { + if (_hashtagResults.empty()) { _hashtagSelected = -1; _hashtagDeleteSelected = false; } else { @@ -519,7 +519,7 @@ void DialogsInner::updateSelected(QPoint localPos) { updateSelectedRow(); } } - if (!_peerSearchResults.isEmpty()) { + if (!_peerSearchResults.empty()) { auto skip = peerSearchOffset(); auto peerSearchSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1; if (peerSearchSelected < 0 || peerSearchSelected >= _peerSearchResults.size()) { @@ -531,7 +531,7 @@ void DialogsInner::updateSelected(QPoint localPos) { updateSelectedRow(); } } - if (_state == SearchedState && !_searchResults.isEmpty()) { + if (_state == SearchedState && !_searchResults.empty()) { auto skip = searchedOffset(); auto searchedSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1; if (searchedSelected < 0 || searchedSelected >= _searchResults.size()) { @@ -718,7 +718,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) { shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex); for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) { shownDialogs()->movePinned(_dragging, -1); - std_::swap_moveable(_pinnedRows[from], _pinnedRows[from - 1]); + std::swap(_pinnedRows[from], _pinnedRows[from - 1]); _pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() - rowHeight, 0); _pinnedRows[from].animStartTime = ms; } @@ -726,7 +726,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) { shift = floorclamp(localPosition.y() - _dragStart.y() + (rowHeight / 2), rowHeight, 0, pinnedCount - _draggingIndex - 1); for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) { shownDialogs()->movePinned(_dragging, 1); - std_::swap_moveable(_pinnedRows[from], _pinnedRows[from + 1]); + std::swap(_pinnedRows[from], _pinnedRows[from + 1]); _pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() + rowHeight, 0); _pinnedRows[from].animStartTime = ms; } @@ -761,7 +761,7 @@ void DialogsInner::step_pinnedShifting(TimeMs ms, bool timer) { auto animating = false; auto updateMin = -1; auto updateMax = 0; - for (auto i = 0, l = _pinnedRows.size(); i != l; ++i) { + for (auto i = 0, l = static_cast(_pinnedRows.size()); i != l; ++i) { auto start = _pinnedRows[i].animStartTime; if (start) { if (updateMin < 0) updateMin = i; @@ -1065,7 +1065,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect ++index; } } - if ((sections & UpdateRowSection::PeerSearch) && !_peerSearchResults.isEmpty()) { + if ((sections & UpdateRowSection::PeerSearch) && !_peerSearchResults.empty()) { auto index = 0, add = peerSearchOffset(); for_const (auto &result, _peerSearchResults) { if (result->peer == peer) { @@ -1075,7 +1075,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect ++index; } } - if ((sections & UpdateRowSection::MessageSearch) && !_searchResults.isEmpty()) { + if ((sections & UpdateRowSection::MessageSearch) && !_searchResults.empty()) { auto index = 0, add = searchedOffset(); for_const (auto &result, _searchResults) { auto item = result->item(); @@ -1185,7 +1185,7 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) { _menu = new Ui::PopupMenu(nullptr); App::main()->fillPeerMenu(_menuPeer, [this](const QString &text, base::lambda &&callback) { - return _menu->addAction(text, std_::move(callback)); + return _menu->addAction(text, std::move(callback)); }, true); connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroyed(QObject*))); _menu->popup(e->globalPos()); @@ -1343,7 +1343,7 @@ void DialogsInner::onFilterUpdate(QString newFilter, bool force) { void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) { if (newFilter.isEmpty() || newFilter.at(0) != '#' || _searchInPeer) { _hashtagFilter = QString(); - if (!_hashtagResults.isEmpty()) { + if (!_hashtagResults.empty()) { _hashtagResults.clear(); refresh(true); setMouseSelection(false, true); @@ -1360,7 +1360,7 @@ void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) { _hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit)); for (auto i = recent.cbegin(), e = recent.cend(); i != e; ++i) { if (i->first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) && i->first.size() + 1 != newFilter.size()) { - _hashtagResults.push_back(std_::make_unique(i->first)); + _hashtagResults.push_back(std::make_unique(i->first)); if (_hashtagResults.size() == kHashtagResultsLimit) break; } } @@ -1505,7 +1505,7 @@ bool DialogsInner::searchReceived(const QVector &messages, DialogsSe if (auto peer = App::peerLoaded(peerId)) { if (lastDate) { auto item = App::histories().addNewMessage(message, NewMessageExisting); - _searchResults.push_back(std_::make_unique(item)); + _searchResults.push_back(std::make_unique(item)); lastDateFound = lastDate; if (isGlobalSearch) { _lastSearchDate = lastDateFound; @@ -1531,7 +1531,7 @@ bool DialogsInner::searchReceived(const QVector &messages, DialogsSe } else { _searchedCount = fullCount; } - if (_state == FilteredState && (!_searchResults.isEmpty() || !_searchInMigrated || type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset)) { + if (_state == FilteredState && (!_searchResults.empty() || !_searchInMigrated || type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset)) { _state = SearchedState; } refresh(); @@ -1550,7 +1550,7 @@ void DialogsInner::peerSearchReceived(const QString &query, const QVector(App::peer(peerId))); + _peerSearchResults.push_back(std::make_unique(App::peer(peerId))); } else { LOG(("API Error: user %1 was not loaded in DialogsInner::peopleReceived()").arg(peerId)); } @@ -1660,7 +1660,7 @@ void DialogsInner::refresh(bool toTop) { } else { if (!_addContactLnk->isHidden()) _addContactLnk->hide(); if (_state == FilteredState) { - h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight) + ((_searchResults.isEmpty() && !_searchInPeer) ? -st::searchedBarHeight : 0); + h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight) + ((_searchResults.empty() && !_searchInPeer) ? -st::searchedBarHeight : 0); } else if (_state == SearchedState) { h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight); } @@ -1707,7 +1707,7 @@ DialogsInner::State DialogsInner::state() const { } bool DialogsInner::hasFilteredResults() const { - return !_filterResults.isEmpty() && _hashtagResults.isEmpty(); + return !_filterResults.isEmpty() && _hashtagResults.empty(); } void DialogsInner::searchInPeer(PeerData *peer) { @@ -1777,23 +1777,23 @@ void DialogsInner::selectSkip(int32 direction) { emit mustScrollTo(fromY, fromY + st::dialogsRowHeight); } } else if (_state == FilteredState || _state == SearchedState) { - if (_hashtagResults.isEmpty() && _filterResults.isEmpty() && _peerSearchResults.isEmpty() && _searchResults.isEmpty()) return; + if (_hashtagResults.empty() && _filterResults.isEmpty() && _peerSearchResults.empty() && _searchResults.empty()) return; if ((_hashtagSelected < 0 || _hashtagSelected >= _hashtagResults.size()) && (_filteredSelected < 0 || _filteredSelected >= _filterResults.size()) && (_peerSearchSelected < 0 || _peerSearchSelected >= _peerSearchResults.size()) && (_searchedSelected < 0 || _searchedSelected >= _searchResults.size())) { - if (_hashtagResults.isEmpty() && _filterResults.isEmpty() && _peerSearchResults.isEmpty()) { + if (_hashtagResults.empty() && _filterResults.isEmpty() && _peerSearchResults.empty()) { _searchedSelected = 0; - } else if (_hashtagResults.isEmpty() && _filterResults.isEmpty()) { + } else if (_hashtagResults.empty() && _filterResults.isEmpty()) { _peerSearchSelected = 0; - } else if (_hashtagResults.isEmpty()) { + } else if (_hashtagResults.empty()) { _filteredSelected = 0; } else { _hashtagSelected = 0; } } else { int32 cur = (_hashtagSelected >= 0 && _hashtagSelected < _hashtagResults.size()) ? _hashtagSelected : ((_filteredSelected >= 0 && _filteredSelected < _filterResults.size()) ? (_hashtagResults.size() + _filteredSelected) : ((_peerSearchSelected >= 0 && _peerSearchSelected < _peerSearchResults.size()) ? (_peerSearchSelected + _filterResults.size() + _hashtagResults.size()) : (_searchedSelected + _peerSearchResults.size() + _filterResults.size() + _hashtagResults.size()))); - cur = snap(cur + direction, 0, _hashtagResults.size() + _filterResults.size() + _peerSearchResults.size() + _searchResults.size() - 1); + cur = snap(cur + direction, 0, static_cast(_hashtagResults.size() + _filterResults.size() + _peerSearchResults.size() + _searchResults.size()) - 1); if (cur < _hashtagResults.size()) { _hashtagSelected = cur; _filteredSelected = _peerSearchSelected = _searchedSelected = -1; @@ -1926,10 +1926,10 @@ void DialogsInner::loadPeerPhotos() { _peerSearchResults[from]->peer->loadUserpic(); } } - from = (yFrom > filteredOffset() + ((_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size(); + from = (yFrom > filteredOffset() + ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size(); if (from < 0) from = 0; if (from < _searchResults.size()) { - int32 to = (yTo > filteredOffset() + (_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size() + 1, w = width(); + int32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size() + 1, w = width(); if (to > _searchResults.size()) to = _searchResults.size(); for (; from < to; ++from) { @@ -2071,7 +2071,7 @@ void DialogsInner::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&ou outMsg = 0; return; } else if (_state == FilteredState || _state == SearchedState) { - if (inMsg && !_searchResults.isEmpty()) { + if (inMsg && !_searchResults.empty()) { for (auto b = _searchResults.cbegin(), i = b + 1, e = _searchResults.cend(); i != e; ++i) { if ((*i)->item()->history()->peer == inPeer && (*i)->item()->id == inMsg) { auto j = i - 1; @@ -2082,7 +2082,7 @@ void DialogsInner::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&ou } if (_searchResults.at(0)->item()->history()->peer == inPeer && _searchResults.at(0)->item()->id == inMsg) { outMsg = ShowAtUnreadMsgId; - if (_peerSearchResults.isEmpty()) { + if (_peerSearchResults.empty()) { if (_filterResults.isEmpty()) { outPeer = nullptr; } else { @@ -2094,12 +2094,12 @@ void DialogsInner::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&ou return; } } - if (!_peerSearchResults.isEmpty() && _peerSearchResults[0]->peer == inPeer) { + if (!_peerSearchResults.empty() && _peerSearchResults[0]->peer == inPeer) { outPeer = _filterResults.isEmpty() ? 0 : _filterResults.back()->history()->peer; outMsg = ShowAtUnreadMsgId; return; } - if (!_peerSearchResults.isEmpty()) { + if (!_peerSearchResults.empty()) { for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) { if ((*i)->peer == inPeer) { outPeer = (*(i - 1))->peer; @@ -2158,7 +2158,7 @@ void DialogsInner::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&out for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) { if ((*i)->peer == inPeer) { ++i; - if (i == e && !_searchResults.isEmpty()) { + if (i == e && !_searchResults.empty()) { outPeer = _searchResults.front()->item()->history()->peer; outMsg = _searchResults.front()->item()->id; } else { @@ -2171,10 +2171,10 @@ void DialogsInner::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&out for (FilteredDialogs::const_iterator i = _filterResults.cbegin(), e = _filterResults.cend(); i != e; ++i) { if ((*i)->history()->peer == inPeer) { ++i; - if (i == e && !_peerSearchResults.isEmpty()) { + if (i == e && !_peerSearchResults.empty()) { outPeer = _peerSearchResults.front()->peer; outMsg = ShowAtUnreadMsgId; - } else if (i == e && !_searchResults.isEmpty()) { + } else if (i == e && !_searchResults.empty()) { outPeer = _searchResults.front()->item()->history()->peer; outMsg = _searchResults.front()->item()->id; } else { diff --git a/Telegram/SourceFiles/dialogswidget.h b/Telegram/SourceFiles/dialogswidget.h index e12b58104e..b2c830bfad 100644 --- a/Telegram/SourceFiles/dialogswidget.h +++ b/Telegram/SourceFiles/dialogswidget.h @@ -113,7 +113,7 @@ public: PeerData *updateFromParentDrag(QPoint globalPos); void setLoadMoreCallback(base::lambda &&callback) { - _loadMoreCallback = std_::move(callback); + _loadMoreCallback = std::move(callback); } void setVisibleTopBottom(int visibleTop, int visibleBottom) override; @@ -152,13 +152,13 @@ protected: private: struct ImportantSwitch; - using DialogsList = std_::unique_ptr; + using DialogsList = std::unique_ptr; using FilteredDialogs = QVector; - using SearchResults = std_::vector_of_moveable>; + using SearchResults = std::vector>; struct HashtagResult; - using HashtagResults = std_::vector_of_moveable>; + using HashtagResults = std::vector>; struct PeerSearchResult; - using PeerSearchResults = std_::vector_of_moveable>; + using PeerSearchResults = std::vector>; void mousePressReleased(Qt::MouseButton button); void clearIrrelevantState(); @@ -228,7 +228,7 @@ private: bool _mouseSelection = false; Qt::MouseButton _pressButton = Qt::LeftButton; - std_::unique_ptr _importantSwitch; + std::unique_ptr _importantSwitch; bool _importantSwitchSelected = false; bool _importantSwitchPressed = false; Dialogs::Row *_selected = nullptr; @@ -242,7 +242,7 @@ private: anim::value yadd; TimeMs animStartTime = 0; }; - std_::vector_of_moveable _pinnedRows; + std::vector _pinnedRows; BasicAnimation _a_pinnedShifting; QList _pinnedOrder; diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 8cba2a5f37..e1a5df9837 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -21,7 +21,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "profile/profile_section_memento.h" -#include "core/vector_of_moveable.h" #include "core/click_handler_types.h" #include "observer_peer.h" #include "mainwindow.h" @@ -40,7 +39,7 @@ namespace App { namespace internal { void CallDelayed(int duration, base::lambda &&lambda) { - QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std_::move(lambda)), SLOT(action())); + QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std::move(lambda)), SLOT(action())); } } // namespace internal @@ -204,7 +203,7 @@ namespace internal { void showBox(object_ptr content, ShowLayerOptions options) { if (auto w = App::wnd()) { - w->ui_showBox(std_::move(content), options); + w->ui_showBox(std::move(content), options); } } diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 51d3732dbc..af50759d2b 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -41,19 +41,19 @@ void CallDelayed(int duration, base::lambda &&lambda); template inline void CallDelayed(int duration, base::internal::lambda_guard &&guarded) { - return internal::CallDelayed(duration, [guarded = std_::move(guarded)] { guarded(); }); + return internal::CallDelayed(duration, [guarded = std::move(guarded)] { guarded(); }); } template inline void CallDelayed(int duration, Pointer &&qobject, PointersAndLambda&&... qobjectsAndLambda) { - auto guarded = base::lambda_guarded(std_::forward(qobject), std_::forward(qobjectsAndLambda)...); - return CallDelayed(duration, std_::move(guarded)); + auto guarded = base::lambda_guarded(std::forward(qobject), std::forward(qobjectsAndLambda)...); + return CallDelayed(duration, std::move(guarded)); } template inline base::lambda LambdaDelayed(int duration, PointersAndLambda&&... qobjectsAndLambda) { - auto guarded = base::lambda_guarded(std_::forward(qobjectsAndLambda)...); - return [guarded = std_::move(guarded), duration] { + auto guarded = base::lambda_guarded(std::forward(qobjectsAndLambda)...); + return [guarded = std::move(guarded), duration] { CallDelayed(duration, guarded.clone()); }; } @@ -90,7 +90,7 @@ void hideMediaPreview(); template QPointer show(object_ptr content, ShowLayerOptions options = CloseOtherLayers) { auto result = QPointer(content.data()); - internal::showBox(std_::move(content), options); + internal::showBox(std::move(content), options); return result; } @@ -209,7 +209,7 @@ inline bool IsTopCorner(ScreenCorner corner) { namespace base { template <> -struct custom_is_fast_copy_type : public std_::true_type { +struct custom_is_fast_copy_type : public std::true_type { }; } // namespace base diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 0c20417ba4..09167cec51 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -106,14 +106,14 @@ void History::setHasPendingResizedItems() { Global::RefHandleHistoryUpdate().call(); } -void History::setLocalDraft(std_::unique_ptr &&draft) { - _localDraft = std_::move(draft); +void History::setLocalDraft(std::unique_ptr &&draft) { + _localDraft = std::move(draft); } void History::takeLocalDraft(History *from) { if (auto &draft = from->_localDraft) { if (!draft->textWithTags.text.isEmpty() && !_localDraft) { - _localDraft = std_::move(draft); + _localDraft = std::move(draft); // Edit and reply to drafts can't migrate. // Cloud drafts do not migrate automatically. @@ -131,7 +131,7 @@ void History::createLocalDraftFromCloud() { auto existing = localDraft(); if (Data::draftIsNull(existing) || !existing->date.isValid() || draft->date >= existing->date) { if (!existing) { - setLocalDraft(std_::make_unique(draft->textWithTags, draft->msgId, draft->cursor, draft->previewCancelled)); + setLocalDraft(std::make_unique(draft->textWithTags, draft->msgId, draft->cursor, draft->previewCancelled)); existing = localDraft(); } else if (existing != draft) { existing->textWithTags = draft->textWithTags; @@ -143,19 +143,19 @@ void History::createLocalDraftFromCloud() { } } -void History::setCloudDraft(std_::unique_ptr &&draft) { - _cloudDraft = std_::move(draft); +void History::setCloudDraft(std::unique_ptr &&draft) { + _cloudDraft = std::move(draft); cloudDraftTextCache.clear(); } Data::Draft *History::createCloudDraft(Data::Draft *fromDraft) { if (Data::draftIsNull(fromDraft)) { - setCloudDraft(std_::make_unique(TextWithTags(), 0, MessageCursor(), false)); + setCloudDraft(std::make_unique(TextWithTags(), 0, MessageCursor(), false)); cloudDraft()->date = QDateTime(); } else { auto existing = cloudDraft(); if (!existing) { - setCloudDraft(std_::make_unique(fromDraft->textWithTags, fromDraft->msgId, fromDraft->cursor, fromDraft->previewCancelled)); + setCloudDraft(std::make_unique(fromDraft->textWithTags, fromDraft->msgId, fromDraft->cursor, fromDraft->previewCancelled)); existing = cloudDraft(); } else if (existing != fromDraft) { existing->textWithTags = fromDraft->textWithTags; @@ -172,8 +172,8 @@ Data::Draft *History::createCloudDraft(Data::Draft *fromDraft) { return cloudDraft(); } -void History::setEditDraft(std_::unique_ptr &&draft) { - _editDraft = std_::move(draft); +void History::setEditDraft(std::unique_ptr &&draft) { + _editDraft = std::move(draft); } void History::clearLocalDraft() { diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 1f424a1ef7..698dd8e367 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -378,12 +378,12 @@ public: Data::Draft *editDraft() { return _editDraft.get(); } - void setLocalDraft(std_::unique_ptr &&draft); + void setLocalDraft(std::unique_ptr &&draft); void takeLocalDraft(History *from); void createLocalDraftFromCloud(); - void setCloudDraft(std_::unique_ptr &&draft); + void setCloudDraft(std::unique_ptr &&draft); Data::Draft *createCloudDraft(Data::Draft *fromDraft); - void setEditDraft(std_::unique_ptr &&draft); + void setEditDraft(std::unique_ptr &&draft); void clearLocalDraft(); void clearCloudDraft(); void clearEditDraft(); @@ -560,14 +560,14 @@ private: int expectedItemsCount = 0; // optimization for block->items.reserve() call HistoryBlock *block = nullptr; }; - std_::unique_ptr _buildingFrontBlock; + std::unique_ptr _buildingFrontBlock; // Creates if necessary a new block for adding item. // Depending on isBuildingFrontBlock() gets front or back block. HistoryBlock *prepareBlockForAddingItem(); - std_::unique_ptr _localDraft, _cloudDraft; - std_::unique_ptr _editDraft; + std::unique_ptr _localDraft, _cloudDraft; + std::unique_ptr _editDraft; using TypingUsers = QMap; TypingUsers _typing; diff --git a/Telegram/SourceFiles/history/history_drag_area.h b/Telegram/SourceFiles/history/history_drag_area.h index 53100e5eaa..d51ad7227e 100644 --- a/Telegram/SourceFiles/history/history_drag_area.h +++ b/Telegram/SourceFiles/history/history_drag_area.h @@ -38,7 +38,7 @@ public: void hideFast(); void setDroppedCallback(base::lambda &&callback) { - _droppedCallback = std_::move(callback); + _droppedCallback = std::move(callback); } protected: diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 25f8f14867..e62c12a71e 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -99,7 +99,7 @@ QString ReplyMarkupClickHandler::buttonText() const { ReplyKeyboard::ReplyKeyboard(const HistoryItem *item, StylePtr &&s) : _item(item) , _a_selected(animation(this, &ReplyKeyboard::step_selected)) - , _st(std_::move(s)) { + , _st(std::move(s)) { if (auto markup = item->Get()) { _rows.reserve(markup->rows.size()); for (int i = 0, l = markup->rows.size(); i != l; ++i) { @@ -197,7 +197,7 @@ bool ReplyKeyboard::isEnoughSpace(int width, const style::BotKeyboardButton &st) } void ReplyKeyboard::setStyle(StylePtr &&st) { - _st = std_::move(st); + _st = std::move(st); } int ReplyKeyboard::naturalWidth() const { @@ -292,7 +292,7 @@ void ReplyKeyboard::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pr if (pressed) { if (!button.ripple) { auto mask = Ui::RippleAnimation::roundRectMask(button.rect.size(), _st->buttonRadius()); - button.ripple = MakeShared(_st->_st->ripple, std_::move(mask), [this] { _st->repaint(_item); }); + button.ripple = MakeShared(_st->_st->ripple, std::move(mask), [this] { _st->repaint(_item); }); } button.ripple->add(_savedCoords - button.rect.topLeft()); } else { diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index e872ba92a9..dbe8fe0e52 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -146,12 +146,12 @@ struct HistoryMessageReply : public RuntimeComponent { HistoryMessageReply &operator=(HistoryMessageReply &&other) { replyToMsgId = other.replyToMsgId; std::swap(replyToMsg, other.replyToMsg); - replyToLnk = std_::move(other.replyToLnk); - replyToName = std_::move(other.replyToName); - replyToText = std_::move(other.replyToText); + replyToLnk = std::move(other.replyToLnk); + replyToName = std::move(other.replyToName); + replyToText = std::move(other.replyToText); replyToVersion = other.replyToVersion; _maxReplyWidth = other._maxReplyWidth; - _replyToVia = std_::move(other._replyToVia); + _replyToVia = std::move(other._replyToVia); return *this; } ~HistoryMessageReply() { @@ -191,7 +191,7 @@ struct HistoryMessageReply : public RuntimeComponent { mutable Text replyToName, replyToText; mutable int replyToVersion = 0; mutable int _maxReplyWidth = 0; - std_::unique_ptr _replyToVia; + std::unique_ptr _replyToVia; int toWidth = 0; }; Q_DECLARE_OPERATORS_FOR_FLAGS(HistoryMessageReply::PaintFlags); @@ -227,7 +227,7 @@ struct HistoryMessageReplyMarkup : public RuntimeComponent inlineKeyboard; + std::unique_ptr inlineKeyboard; // If >= 0 it holds the y coord of the inlineKeyboard before the last edition. int oldTop = -1; @@ -313,7 +313,7 @@ public: friend class ReplyKeyboard; }; - typedef std_::unique_ptr