c++20: use std::erase(_if) instead of std::remove(_if)+erase (part 11)
Change-Id: I2197c65248a96caa8ae621d5b1d16aa1086fc525 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159643 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
parent
7ad4641e79
commit
8158f016ea
13 changed files with 66 additions and 38 deletions
|
@ -134,13 +134,11 @@ void PointerSymbol::viewAdded( const UnoViewSharedPtr& rView )
|
||||||
|
|
||||||
void PointerSymbol::viewRemoved( const UnoViewSharedPtr& rView )
|
void PointerSymbol::viewRemoved( const UnoViewSharedPtr& rView )
|
||||||
{
|
{
|
||||||
maViews.erase(
|
std::erase_if(
|
||||||
std::remove_if(
|
maViews,
|
||||||
maViews.begin(), maViews.end(),
|
|
||||||
[&rView]
|
[&rView]
|
||||||
( const ViewsVecT::value_type& cp )
|
( const ViewsVecT::value_type& cp )
|
||||||
{ return rView == cp.first; } ),
|
{ return rView == cp.first; } );
|
||||||
maViews.end() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointerSymbol::viewChanged( const UnoViewSharedPtr& rView )
|
void PointerSymbol::viewChanged( const UnoViewSharedPtr& rView )
|
||||||
|
|
|
@ -349,12 +349,11 @@ void RehearseTimingsActivity::viewAdded( const UnoViewSharedPtr& rView )
|
||||||
|
|
||||||
void RehearseTimingsActivity::viewRemoved( const UnoViewSharedPtr& rView )
|
void RehearseTimingsActivity::viewRemoved( const UnoViewSharedPtr& rView )
|
||||||
{
|
{
|
||||||
maViews.erase(
|
std::erase_if(
|
||||||
std::remove_if( maViews.begin(), maViews.end(),
|
maViews,
|
||||||
[&rView]
|
[&rView]
|
||||||
( const ViewsVecT::value_type& cp )
|
( const ViewsVecT::value_type& cp )
|
||||||
{ return rView == cp.first; } ),
|
{ return rView == cp.first; } );
|
||||||
maViews.end() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RehearseTimingsActivity::viewChanged( const UnoViewSharedPtr& rView )
|
void RehearseTimingsActivity::viewChanged( const UnoViewSharedPtr& rView )
|
||||||
|
|
|
@ -184,6 +184,8 @@ namespace slideshow::internal
|
||||||
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
||||||
"AppletShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"AppletShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
|
// TODO : needed for the moment since ANDROID doesn't know size_t return from std::erase_if
|
||||||
|
#if defined ANDROID
|
||||||
ViewAppletShapeVector::iterator aIter;
|
ViewAppletShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewAppletShapes.begin(),
|
if( (aIter=::std::remove_if( maViewAppletShapes.begin(),
|
||||||
|
@ -200,6 +202,14 @@ namespace slideshow::internal
|
||||||
maViewAppletShapes.erase( aIter, aEnd );
|
maViewAppletShapes.erase( aIter, aEnd );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
size_t nb = std::erase_if(maViewAppletShapes,
|
||||||
|
[&rLayer]
|
||||||
|
( const ViewAppletShapeSharedPtr& pShape )
|
||||||
|
{ return rLayer == pShape->getViewLayer(); } );
|
||||||
|
// if nb == 0, it means view layer seemingly was not added, failed
|
||||||
|
return (nb != 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,8 @@ namespace slideshow::internal
|
||||||
{ return pBgShape->getViewLayer() == rLayer; } ) < 2,
|
{ return pBgShape->getViewLayer() == rLayer; } ) < 2,
|
||||||
"BackgroundShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"BackgroundShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
|
// TODO : needed for the moment since ANDROID doesn't know size_t return from std::erase_if
|
||||||
|
#if defined ANDROID
|
||||||
ViewBackgroundShapeVector::iterator aIter;
|
ViewBackgroundShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewShapes.begin(),
|
if( (aIter=::std::remove_if( maViewShapes.begin(),
|
||||||
|
@ -202,6 +204,14 @@ namespace slideshow::internal
|
||||||
maViewShapes.erase( aIter, aEnd );
|
maViewShapes.erase( aIter, aEnd );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
|
||||||
|
size_t nb = std::erase_if(maViewShapes,
|
||||||
|
[&rLayer]( const ViewBackgroundShapeSharedPtr& pBgShape )
|
||||||
|
{ return pBgShape->getViewLayer() == rLayer; } );
|
||||||
|
// if nb == 0, it means view shape seemingly was not added, failed
|
||||||
|
return (nb != 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundShape::clearAllViewLayers()
|
void BackgroundShape::clearAllViewLayers()
|
||||||
|
|
|
@ -659,6 +659,9 @@ namespace slideshow::internal
|
||||||
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
||||||
"DrawShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"DrawShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
|
|
||||||
|
// TODO : needed for the moment since ANDROID doesn't know size_t return from std::erase_if
|
||||||
|
#if defined ANDROID
|
||||||
ViewShapeVector::iterator aIter;
|
ViewShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewShapes.begin(),
|
if( (aIter=::std::remove_if( maViewShapes.begin(),
|
||||||
|
@ -675,6 +678,14 @@ namespace slideshow::internal
|
||||||
maViewShapes.erase( aIter, aEnd );
|
maViewShapes.erase( aIter, aEnd );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
size_t nb = std::erase_if(maViewShapes,
|
||||||
|
[&rLayer]
|
||||||
|
( const ViewShapeSharedPtr& pShape )
|
||||||
|
{ return rLayer == pShape->getViewLayer(); } );
|
||||||
|
// if nb == 0, it means view shape seemingly was not added, failed
|
||||||
|
return (nb != 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawShape::clearAllViewLayers()
|
void DrawShape::clearAllViewLayers()
|
||||||
|
|
|
@ -149,6 +149,8 @@ namespace slideshow::internal
|
||||||
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
{ return rLayer == pShape->getViewLayer(); } ) < 2,
|
||||||
"MediaShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
"MediaShape::removeViewLayer(): Duplicate ViewLayer entries!" );
|
||||||
|
|
||||||
|
// TODO : needed for the moment since ANDROID doesn't know size_t return from std::erase_if
|
||||||
|
#if defined ANDROID
|
||||||
ViewMediaShapeVector::iterator aIter;
|
ViewMediaShapeVector::iterator aIter;
|
||||||
|
|
||||||
if( (aIter=::std::remove_if( maViewMediaShapes.begin(),
|
if( (aIter=::std::remove_if( maViewMediaShapes.begin(),
|
||||||
|
@ -165,6 +167,14 @@ namespace slideshow::internal
|
||||||
maViewMediaShapes.erase( aIter, aEnd );
|
maViewMediaShapes.erase( aIter, aEnd );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
size_t nb = std::erase_if(maViewMediaShapes,
|
||||||
|
[&rLayer]
|
||||||
|
( const ViewMediaShapeSharedPtr& pShape )
|
||||||
|
{ return rLayer == pShape->getViewLayer(); } );
|
||||||
|
// if nb == 0, it means view media shape seemingly was not added, failed
|
||||||
|
return (nb != 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -601,14 +601,10 @@ void SlideImpl::viewRemoved( const UnoViewSharedPtr& rView )
|
||||||
if( mpLayerManager )
|
if( mpLayerManager )
|
||||||
mpLayerManager->viewRemoved( rView );
|
mpLayerManager->viewRemoved( rView );
|
||||||
|
|
||||||
const VectorOfVectorOfSlideBitmaps::iterator aEnd( maSlideBitmaps.end() );
|
std::erase_if(maSlideBitmaps,
|
||||||
maSlideBitmaps.erase(
|
|
||||||
std::remove_if( maSlideBitmaps.begin(),
|
|
||||||
aEnd,
|
|
||||||
[&rView]
|
[&rView]
|
||||||
( const VectorOfVectorOfSlideBitmaps::value_type& cp )
|
( const VectorOfVectorOfSlideBitmaps::value_type& cp )
|
||||||
{ return rView == cp.first; } ),
|
{ return rView == cp.first; } );
|
||||||
aEnd );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideImpl::viewChanged( const UnoViewSharedPtr& rView )
|
void SlideImpl::viewChanged( const UnoViewSharedPtr& rView )
|
||||||
|
|
|
@ -89,9 +89,7 @@ namespace slideshow::internal
|
||||||
|
|
||||||
virtual void viewRemoved( const UnoViewSharedPtr& rView ) override
|
virtual void viewRemoved( const UnoViewSharedPtr& rView ) override
|
||||||
{
|
{
|
||||||
maViews.erase( ::std::remove( maViews.begin(),
|
std::erase(maViews, rView);
|
||||||
maViews.end(),
|
|
||||||
rView ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void viewChanged( const UnoViewSharedPtr& /*rView*/ ) override
|
virtual void viewChanged( const UnoViewSharedPtr& /*rView*/ ) override
|
||||||
|
|
|
@ -124,10 +124,7 @@ void SlideOverlayButton::viewAdded(const UnoViewSharedPtr& rView)
|
||||||
|
|
||||||
void SlideOverlayButton::viewRemoved(const UnoViewSharedPtr& rView)
|
void SlideOverlayButton::viewRemoved(const UnoViewSharedPtr& rView)
|
||||||
{
|
{
|
||||||
maViews.erase(
|
std::erase_if(maViews, [&rView](const ViewsVecT::value_type& cp) { return rView == cp.first; });
|
||||||
std::remove_if(maViews.begin(), maViews.end(),
|
|
||||||
[&rView](const ViewsVecT::value_type& cp) { return rView == cp.first; }),
|
|
||||||
maViews.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideOverlayButton::viewChanged(const UnoViewSharedPtr& rView)
|
void SlideOverlayButton::viewChanged(const UnoViewSharedPtr& rView)
|
||||||
|
|
|
@ -404,13 +404,9 @@ void SlideChangeBase::viewRemoved( const UnoViewSharedPtr& rView )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// erase corresponding entry from maViewData
|
// erase corresponding entry from maViewData
|
||||||
maViewData.erase(
|
std::erase_if(maViewData,
|
||||||
std::remove_if(
|
|
||||||
maViewData.begin(),
|
|
||||||
maViewData.end(),
|
|
||||||
[rView]( const ViewEntry& rViewEntry )
|
[rView]( const ViewEntry& rViewEntry )
|
||||||
{ return rView == rViewEntry.getView(); } ),
|
{ return rView == rViewEntry.getView(); } );
|
||||||
maViewData.end() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideChangeBase::viewChanged( const UnoViewSharedPtr& rView )
|
void SlideChangeBase::viewChanged( const UnoViewSharedPtr& rView )
|
||||||
|
|
|
@ -138,13 +138,11 @@ void WaitSymbol::viewAdded( const UnoViewSharedPtr& rView )
|
||||||
|
|
||||||
void WaitSymbol::viewRemoved( const UnoViewSharedPtr& rView )
|
void WaitSymbol::viewRemoved( const UnoViewSharedPtr& rView )
|
||||||
{
|
{
|
||||||
maViews.erase(
|
std::erase_if(
|
||||||
std::remove_if(
|
maViews,
|
||||||
maViews.begin(), maViews.end(),
|
|
||||||
[&rView]
|
[&rView]
|
||||||
( const ViewsVecT::value_type& cp )
|
( const ViewsVecT::value_type& cp )
|
||||||
{ return rView == cp.first; } ),
|
{ return rView == cp.first; } );
|
||||||
maViews.end() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitSymbol::viewChanged( const UnoViewSharedPtr& rView )
|
void WaitSymbol::viewChanged( const UnoViewSharedPtr& rView )
|
||||||
|
|
|
@ -299,6 +299,8 @@ public:
|
||||||
{
|
{
|
||||||
Guard aGuard(*this);
|
Guard aGuard(*this);
|
||||||
|
|
||||||
|
// TODO : needed for the moment since ANDROID doesn't know size_t return from std::erase
|
||||||
|
#if defined ANDROID
|
||||||
const typename container_type::iterator aEnd( maListeners.end() );
|
const typename container_type::iterator aEnd( maListeners.end() );
|
||||||
typename container_type::iterator aIter;
|
typename container_type::iterator aIter;
|
||||||
if( (aIter=std::remove(maListeners.begin(),
|
if( (aIter=std::remove(maListeners.begin(),
|
||||||
|
@ -311,6 +313,11 @@ public:
|
||||||
maListeners.erase( aIter, aEnd );
|
maListeners.erase( aIter, aEnd );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
size_t nb = std::erase(maListeners, rListener);
|
||||||
|
// if nb == 0, it means listener wasn't found
|
||||||
|
return (nb != 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all listeners in one go
|
/// Removes all listeners in one go
|
||||||
|
|
|
@ -126,13 +126,11 @@ private:
|
||||||
{ return cp.first == rNewLayer; } ) )
|
{ return cp.first == rNewLayer; } ) )
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
|
||||||
maViewLayers.erase(
|
std::erase_if(
|
||||||
std::remove_if(
|
maViewLayers,
|
||||||
maViewLayers.begin(),
|
|
||||||
maViewLayers.end(),
|
|
||||||
[&rNewLayer]
|
[&rNewLayer]
|
||||||
( const ViewVector::value_type& cp )
|
( const ViewVector::value_type& cp )
|
||||||
{ return cp.first == rNewLayer; } ) );
|
{ return cp.first == rNewLayer; } );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void clearAllViewLayers() override
|
virtual void clearAllViewLayers() override
|
||||||
|
|
Loading…
Reference in a new issue