summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2023-11-19 21:29:12 +0100
committerJulien Nabet <serval2412@yahoo.fr>2023-11-20 12:06:28 +0100
commit950bee9154c9854364c72a3b48ddbcffff137803 (patch)
treef5f0efae1aa7be262f1a4b8bc320cb9d67c086f5
parenta7de97bc7b83790907bd6fdfb7a319e2467aba1d (diff)
c++20: use std::erase(_if) instead of std::remove(_if)+erase (sw)
Change-Id: I67c231441b56f05da001beab5b893bc6a6a6a392 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159704 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--sw/inc/doc.hxx5
-rw-r--r--sw/source/core/attr/calbck.cxx7
-rw-r--r--sw/source/core/edit/edfcol.cxx6
-rw-r--r--sw/source/core/inc/layfrm.hxx5
-rw-r--r--sw/source/core/txtnode/attrcontentcontrol.cxx4
-rw-r--r--sw/source/core/txtnode/fmtatr2.cxx5
-rw-r--r--sw/source/core/unocore/unochart.cxx4
-rw-r--r--sw/source/core/unocore/unoobj2.cxx3
-rw-r--r--sw/source/core/view/viewsh.cxx2
-rw-r--r--sw/source/filter/html/htmltab.cxx2
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx3
-rw-r--r--sw/source/ui/dbui/mmaddressblockpage.cxx2
-rw-r--r--sw/source/ui/misc/bookmark.cxx4
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx2
-rw-r--r--sw/source/uibase/uiview/uivwimp.cxx4
-rw-r--r--sw/source/uibase/uno/unodispatch.cxx7
-rw-r--r--sw/source/uibase/utlui/content.cxx3
17 files changed, 24 insertions, 44 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5d1814210801..ea95cef85636 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1675,10 +1675,7 @@ public:
{
auto & rTable = const_cast<SwDoc*>(this)->mvUnoCursorTable;
// In most cases we'll remove most of the elements.
- rTable.erase( std::remove_if(rTable.begin(),
- rTable.end(),
- [] (std::weak_ptr<SwUnoCursor> const & x) { return x.expired(); }),
- rTable.end());
+ std::erase_if(rTable, [] (std::weak_ptr<SwUnoCursor> const & x) { return x.expired(); });
}
/**
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 81a249203dc8..871dff43477b 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -284,13 +284,12 @@ bool sw::WriterMultiListener::IsListeningTo(const SwModify* const pBroadcaster)
void sw::WriterMultiListener::EndListening(SwModify* pBroadcaster)
{
- m_vDepends.erase(
- std::remove_if( m_vDepends.begin(), m_vDepends.end(),
+ std::erase_if(
+ m_vDepends,
[&pBroadcaster](const ListenerEntry& aListener)
{
return aListener.GetRegisteredIn() == nullptr || aListener.GetRegisteredIn() == pBroadcaster;
- }),
- m_vDepends.end());
+ });
}
void sw::WriterMultiListener::EndListeningAll()
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 2ce0caa01f91..f02273e07318 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1190,11 +1190,9 @@ static void lcl_ApplyParagraphClassification(SwDoc* pDoc,
// need to insert in reverse order.
std::reverse(aResults.begin(), aResults.end());
// Ignore "PARAGRAPH" types
- aResults.erase(std::remove_if(aResults.begin(),
- aResults.end(),
+ std::erase_if(aResults,
[](const svx::ClassificationResult& rResult)-> bool
- { return rResult.meType == svx::ClassificationType::PARAGRAPH; }),
- aResults.end());
+ { return rResult.meType == svx::ClassificationType::PARAGRAPH; });
sfx::ClassificationKeyCreator aKeyCreator(SfxClassificationHelper::getPolicyType());
std::vector<OUString> aFieldNames;
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 52e22829d4ad..981fbb34f649 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -178,10 +178,7 @@ public:
void ClearVertPosOrientFrameFor(SwAnchoredObject *pObj)
{
- m_VertPosOrientFramesFor.erase(
- std::remove(m_VertPosOrientFramesFor.begin(),
- m_VertPosOrientFramesFor.end(), pObj),
- m_VertPosOrientFramesFor.end());
+ std::erase(m_VertPosOrientFramesFor, pObj);
}
void dumpAsXmlAttributes(xmlTextWriterPtr writer) const override;
};
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 1782f23fb526..c894615fa41d 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -830,9 +830,7 @@ void SwContentControlManager::Insert(SwTextContentControl* pTextContentControl)
void SwContentControlManager::Erase(SwTextContentControl* pTextContentControl)
{
- m_aContentControls.erase(
- std::remove(m_aContentControls.begin(), m_aContentControls.end(), pTextContentControl),
- m_aContentControls.end());
+ std::erase(m_aContentControls, pTextContentControl);
}
SwTextContentControl* SwContentControlManager::Get(size_t nIndex)
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index 3a57680fa51b..3e888b660f6a 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -832,10 +832,7 @@ std::vector< uno::Reference<text::XTextField> >
MetaFieldManager::getMetaFields()
{
// erase deleted fields
- const MetaFieldList_t::iterator iter(
- std::remove_if(m_MetaFields.begin(), m_MetaFields.end(),
- [] (std::weak_ptr<MetaField> const& rField) { return rField.expired(); }));
- m_MetaFields.erase(iter, m_MetaFields.end());
+ std::erase_if(m_MetaFields, [] (std::weak_ptr<MetaField> const& rField) { return rField.expired(); });
// filter out fields in UNDO
MetaFieldList_t filtered(m_MetaFields.size());
const MetaFieldList_t::iterator iter2(
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index a98f16595643..db97093a3184 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1424,11 +1424,11 @@ void SwChartDataProvider::AddDataSequence( const SwTable &rTable, rtl::Reference
void SwChartDataProvider::RemoveDataSequence( const SwTable &rTable, rtl::Reference< SwChartDataSequence > const &rxDataSequence )
{
Vec_DataSequenceRef_t& rVec = m_aDataSequences[ &rTable ];
- rVec.erase( std::remove_if(rVec.begin(), rVec.end(),
+ std::erase_if(rVec,
[&rxDataSequence](const unotools::WeakReference < SwChartDataSequence >& i)
{
return i.get() == rxDataSequence;
- }), rVec.end());
+ });
}
void SwChartDataProvider::InvalidateTable( const SwTable *pTable, bool bImmediate )
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 6e9bf1cfe7e1..e4f5ccdf22d9 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -1713,9 +1713,8 @@ struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
else
{
// removing orphaned Clients
- const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
+ std::erase_if(m_vFrames,
[] (std::unique_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
- m_vFrames.erase(iter, m_vFrames.end());
}
}
void FillFrame();
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index a77d0ccc8bcf..7a322ed7a45f 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -541,7 +541,7 @@ void SwViewShell::InvalidateAll(std::vector<LockPaintReason>& rReasons)
{
// https://github.com/CollaboraOnline/online/issues/6379
// ditch OuterResize as a reason to invalidate all in the online case
- rReasons.erase(std::remove(rReasons.begin(), rReasons.end(), LockPaintReason::OuterResize), rReasons.end());
+ std::erase(rReasons, LockPaintReason::OuterResize);
}
if (!rReasons.empty())
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 8b4756986f27..424644378bc5 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -1055,7 +1055,7 @@ void SwHTMLParser::DeregisterHTMLTable(HTMLTable* pOld)
{
if (pOld->m_xBox1)
m_aOrphanedTableBoxes.emplace_back(std::move(pOld->m_xBox1));
- m_aTables.erase(std::remove(m_aTables.begin(), m_aTables.end(), pOld));
+ std::erase(m_aTables, pOld);
}
SwDoc* SwHTMLParser::GetDoc() const
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index aa552fe3e78a..529100289737 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -655,8 +655,7 @@ namespace sw
}
}
- aRunChanges.erase(std::remove_if(aRunChanges.begin(),
- aRunChanges.end(), myImplHelpers::IfBeforeStart(0/*nTextStart*/)), aRunChanges.end());
+ std::erase_if(aRunChanges, myImplHelpers::IfBeforeStart(0/*nTextStart*/));
return aRunChanges;
}
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 48d4e3dce117..73811cbf3e0e 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -1523,7 +1523,7 @@ namespace
virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) override
{
- m_aListeners.erase(std::remove(m_aListeners.begin(), m_aListeners.end(), xListener), m_aListeners.end());
+ std::erase(m_aListeners, xListener);
}
virtual sal_Bool SAL_CALL isActive() override
diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx
index 4eafb8c1264a..6431809c9569 100644
--- a/sw/source/ui/misc/bookmark.cxx
+++ b/sw/source/ui/misc/bookmark.cxx
@@ -110,9 +110,7 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, DeleteHdl, weld::Button&, void)
SfxRequest aReq(m_rSh.GetView().GetViewFrame(), FN_DELETE_BOOKMARK);
aReq.AppendItem(SfxStringItem(FN_DELETE_BOOKMARK, sRemoved));
aReq.Done();
- m_aTableBookmarks.erase(std::remove(m_aTableBookmarks.begin(), m_aTableBookmarks.end(),
- std::make_pair(pBookmark, sRemoved)),
- m_aTableBookmarks.end());
+ std::erase(m_aTableBookmarks, std::make_pair(pBookmark, sRemoved));
++nSelectedRows;
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 9419e6ad009d..12c5e4f52d11 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -1472,7 +1472,7 @@ class FieldDocWatchingStack : public SfxListener
if (!bAllInvalidated && m_rFilter(pField))
{
EndListening(const_cast<SwFormatField&>(*pField));
- m_aFormatFields.erase(std::remove(m_aFormatFields.begin(), m_aFormatFields.end(), pField), m_aFormatFields.end());
+ std::erase(m_aFormatFields, pField);
}
}
else if (pHint->Which() == SwFormatFieldHintWhich::INSERTED)
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index 06871734d844..71f97dbbc9d1 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -221,10 +221,10 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
osl_atomic_increment(&rTransferable.m_refCount);
{
// Remove previously added, but no longer existing weak references.
- mxTransferables.erase(std::remove_if(mxTransferables.begin(), mxTransferables.end(),
+ std::erase_if(mxTransferables,
[](const unotools::WeakReference<SwTransferable>& rTunnel) {
return !rTunnel.get();
- }), mxTransferables.end());
+ });
mxTransferables.emplace_back(&rTransferable);
}
diff --git a/sw/source/uibase/uno/unodispatch.cxx b/sw/source/uibase/uno/unodispatch.cxx
index bb9af96d48f6..a67afc31c19d 100644
--- a/sw/source/uibase/uno/unodispatch.cxx
+++ b/sw/source/uibase/uno/unodispatch.cxx
@@ -300,10 +300,9 @@ void SwXDispatch::addStatusListener(
void SwXDispatch::removeStatusListener(
const uno::Reference< frame::XStatusListener >& xControl, const util::URL& )
{
- m_aStatusListenerVector.erase(
- std::remove_if(m_aStatusListenerVector.begin(), m_aStatusListenerVector.end(),
- [&](const StatusStruct_Impl& status) { return status.xListener.get() == xControl.get(); }),
- m_aStatusListenerVector.end());
+ std::erase_if(
+ m_aStatusListenerVector,
+ [&](const StatusStruct_Impl& status) { return status.xListener.get() == xControl.get(); });
if(m_aStatusListenerVector.empty() && m_pView)
{
uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 5dc3d87aaf14..770f8b41e705 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2219,8 +2219,7 @@ bool SwContentTree::RequestingChildren(const weld::TreeIter& rParent)
m_xTreeView->set_extra_row_indent(*xChild, nLevel + 1 - m_xTreeView->get_iter_depth(*xChild));
// remove any parent candidates equal to or higher than this node
- aParentCandidates.erase(std::remove_if(aParentCandidates.begin(), aParentCandidates.end(),
- std::not_fn(lambda)), aParentCandidates.end());
+ std::erase_if(aParentCandidates, std::not_fn(lambda));
// add this node as a parent candidate for any following nodes at a higher outline level
aParentCandidates.emplace_back(m_xTreeView->make_iterator(xChild.get()));