From 2fbaba8aa42b7cd4cbaa774f6d92e6d690614262 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Fri, 2 Sep 2022 08:52:14 +0100 Subject: [PATCH] util: Add Erase and EraseIf helpers No std::erase_if in C++17 which is handy to have! --- vphysics_jolt/vjolt_util.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vphysics_jolt/vjolt_util.h b/vphysics_jolt/vjolt_util.h index 52f4ef3..4ae1a18 100644 --- a/vphysics_jolt/vjolt_util.h +++ b/vphysics_jolt/vjolt_util.h @@ -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() ); +}