c++20: use std::erase(_if) instead of std::remove(_if)+erase (part 8)

Change-Id: Ia726fbbfd3f08eb4bb5c7ccaf10d65fe01ca6585
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159639
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Julien Nabet 2023-11-18 21:22:57 +01:00
parent f566a73adc
commit 7ad4641e79
10 changed files with 15 additions and 25 deletions

View file

@ -3627,7 +3627,7 @@ bool ScDPCollection::GetReferenceGroups(const ScDPObject& rDPObj, const ScDPDime
void ScDPCollection::DeleteOnTab( SCTAB nTab )
{
maTables.erase( std::remove_if(maTables.begin(), maTables.end(), MatchByTable(nTab)), maTables.end());
std::erase_if(maTables, MatchByTable(nTab));
}
void ScDPCollection::UpdateReference( UpdateRefMode eUpdateRefMode,
@ -3765,7 +3765,7 @@ void ScDPCollection::FreeTable(const ScDPObject* pDPObject)
return pCurrent.get() == pDPObject;
};
maTables.erase(std::remove_if(maTables.begin(), maTables.end(), funcRemoveCondition), maTables.end());
std::erase_if(maTables, funcRemoveCondition);
}
ScDPObject* ScDPCollection::InsertNewTable(std::unique_ptr<ScDPObject> pDPObj)

View file

@ -302,7 +302,7 @@ void ScDPSaveDimension::AddMember(std::unique_ptr<ScDPSaveMember> pMember)
}
else
{
maMemberList.erase(std::remove(maMemberList.begin(), maMemberList.end(), aExisting->second.get()), maMemberList.end());
std::erase(maMemberList, aExisting->second.get());
aExisting->second = std::move(pMember);
}
maMemberList.push_back( tmp );
@ -471,7 +471,7 @@ void ScDPSaveDimension::SetMemberPosition( const OUString& rName, sal_Int32 nNew
{
ScDPSaveMember* pMember = GetMemberByName( rName ); // make sure it exists and is in the hash
maMemberList.erase(std::remove( maMemberList.begin(), maMemberList.end(), pMember), maMemberList.end() );
std::erase(maMemberList, pMember);
maMemberList.insert( maMemberList.begin() + nNewPos, pMember );
}

View file

@ -1329,7 +1329,7 @@ const ScDBData* ScDBCollection::AnonDBs::findByRange(const ScRange& rRange) cons
void ScDBCollection::AnonDBs::deleteOnTab(SCTAB nTab)
{
FindByTable func(nTab);
m_DBs.erase(std::remove_if(m_DBs.begin(), m_DBs.end(), func), m_DBs.end());
std::erase_if(m_DBs, func);
}
ScDBData* ScDBCollection::AnonDBs::getByRange(const ScRange& rRange)

View file

@ -29,11 +29,10 @@ ScDetOpList::ScDetOpList(const ScDetOpList& rList) :
void ScDetOpList::DeleteOnTab( SCTAB nTab )
{
aDetOpDataVector.erase(std::remove_if(aDetOpDataVector.begin(), aDetOpDataVector.end(),
std::erase_if(aDetOpDataVector,
[&nTab](const ScDetOpData& rxDetOpData) {
return rxDetOpData.GetPos().Tab() == nTab; // look for operations on the deleted sheet
}),
aDetOpDataVector.end());
});
}
void ScDetOpList::UpdateReference( const ScDocument* pDoc, UpdateRefMode eUpdateRefMode,

View file

@ -1268,12 +1268,11 @@ void ScRangePairList::UpdateReference( UpdateRefMode eUpdateRefMode,
// Delete entries that have the labels (first range) on nTab
void ScRangePairList::DeleteOnTab( SCTAB nTab )
{
maPairs.erase(std::remove_if(maPairs.begin(), maPairs.end(),
std::erase_if(maPairs,
[&nTab](const ScRangePair& rR) {
const ScRange & rRange = rR.GetRange(0);
return (rRange.aStart.Tab() == nTab) && (rRange.aEnd.Tab() == nTab);
}),
maPairs.end());
});
}
ScRangePair* ScRangePairList::Find( const ScAddress& rAdr )

View file

@ -395,9 +395,7 @@ public:
void InvalidateRecord( size_t nPos ) { maRecs[ nPos ] = nullptr; }
void RemoveInvalidatedRecords()
{
maRecs.erase(
std::remove_if( maRecs.begin(), maRecs.end(), [](const RecordRefType& xRec) { return xRec == nullptr; } ),
maRecs.end());
std::erase_if(maRecs, [](const RecordRefType& xRec) { return xRec == nullptr; } );
}
private:

View file

@ -54,9 +54,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL ScXMLConditio
IMPL_LINK(ScXMLConditionalFormatsContext, FormatDeletedHdl, ScConditionalFormat*, pFormat, void)
{
mvCondFormatData.erase(std::remove_if(mvCondFormatData.begin(), mvCondFormatData.end(),
[pFormat](CondFormatData& r){ return r.mpFormat == pFormat; }),
mvCondFormatData.end());
std::erase_if(mvCondFormatData, [pFormat](CondFormatData& r){ return r.mpFormat == pFormat; });
}
void SAL_CALL ScXMLConditionalFormatsContext::endFastElement( sal_Int32 /*nElement*/ )

View file

@ -63,7 +63,7 @@ public:
{
for (auto& rEntry : maCells)
{
rEntry.second.erase(std::remove(rEntry.second.begin(), rEntry.second.end(), pCell), rEntry.second.end() );
std::erase(rEntry.second, pCell);
}
}

View file

@ -1343,9 +1343,7 @@ void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Referenc
{
SolarMutexGuard aGuard;
sal_uInt16 nCount = aMouseClickHandlers.size();
aMouseClickHandlers.erase(
std::remove(aMouseClickHandlers.begin(), aMouseClickHandlers.end(), aListener),
aMouseClickHandlers.end());
std::erase(aMouseClickHandlers, aListener);
if (aMouseClickHandlers.empty() && (nCount > 0)) // only if last listener removed
EndMouseListening();
}
@ -1366,9 +1364,7 @@ void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference<
{
SolarMutexGuard aGuard;
sal_uInt16 nCount = aActivationListeners.size();
aActivationListeners.erase(
std::remove(aActivationListeners.begin(), aActivationListeners.end(), aListener),
aActivationListeners.end());
std::erase(aActivationListeners, aListener);
if (aActivationListeners.empty() && (nCount > 0)) // only if last listener removed
EndActivationListening();
}

View file

@ -1542,7 +1542,7 @@ void ScGridWindow::LaunchDataSelectMenu(const SCCOL nCol, const SCROW nRow)
if (pData && !pData->IsIgnoreBlank())
{
auto lambda = [](const ScTypedStrData& rStr) { return rStr.GetString().isEmpty(); };
aStrings.erase(std::remove_if(aStrings.begin(), aStrings.end(), lambda), aStrings.end());
std::erase_if(aStrings, lambda);
}
if (aStrings.empty())