util: Add Erase and EraseIf helpers

No std::erase_if in C++17 which is handy to have!
This commit is contained in:
Joshua Ashton 2022-09-02 08:52:14 +01:00 committed by Joshie
parent 9a44e687c6
commit cb10f30fd8
1 changed files with 13 additions and 0 deletions

View File

@ -362,3 +362,16 @@ inline uint32 tzcnt( uint32 n )
#endif
}
template< typename T, typename Value >
constexpr void Erase( T &c, const Value &value )
{
auto it = std::remove( c.begin(), c.end(), value );
c.erase( it, c.end() );
}
template< typename T, typename Pred >
constexpr void EraseIf( T &c, Pred pred )
{
auto it = std::remove_if( c.begin(), c.end(), pred );
c.erase( it, c.end() );
}