Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r3c09d47 r2bf9c37  
    172172auto filter(Args&&... args) -> decltype(std::copy_if(std::forward<Args>(args)...)) {
    173173  return std::copy_if(std::forward<Args>(args)...);
     174}
     175
     176template <typename E, typename UnaryPredicate, template< typename, typename...> class Container, typename... Args >
     177void filter( Container< E *, Args... > & container, UnaryPredicate pred, bool doDelete ) {
     178        auto i = begin( container );
     179        while ( i != end( container ) ) {
     180                auto it = next( i );
     181                if ( pred( *i ) ) {
     182                        if ( doDelete ) {
     183                                delete *i;
     184                        } // if
     185                        container.erase( i );
     186                } // if
     187                i = it;
     188        } // while
    174189}
    175190
Note: See TracChangeset for help on using the changeset viewer.