Skip to content

Invoke <container>::erase after remove_if

std::remove_if does not really remove the objects, so we must invoke ::erase after the call to remove_if. This is enforced in gcc 14 because remove_if is flagged "nodiscard".

Fixes the warning (gcc 14):

Lbcom/UT/UTAlgorithms/src/UTLiteClusterKiller.cpp:44:19: warning: ignoring return value of 'constexpr _FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<LHCb::UTLiteCluster*, vector<LHCb::UTLiteCluster, allocator<LHCb::UTLiteCluster> > >; _Predicate = UTLiteClusterKiller::execute(const EventContext&) const::<lambda(const LHCb::UTLiteCluster&)>]', declared with attribute 'nodiscard' [-Wunused-result]
   44 |     std::remove_if( clusterCont->begin(), clusterCont->end(),
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |                     [&]( const LHCb::UTLiteCluster& c ) { return ( *m_clusterSelector )( c.channelID(), det ); } );
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: requires LHCb!5067 (merged)

Merge request reports

Loading