diff --git a/src/common/container_helpers.h b/src/common/container_helpers.h index 5824c9c37..2048de8d0 100644 --- a/src/common/container_helpers.h +++ b/src/common/container_helpers.h @@ -167,4 +167,15 @@ void for_all_in_map_erase_if(std::unordered_map &map_inout, PredT } } +/// erase with a reverse iterator +/// returned iterator is (pos + 1) if pos hadn't been erased +template +ReverseIteratorT reverse_erase(ContainerT &container, ReverseIteratorT pos) +{ + static_assert(std::is_same_v + || std::is_same_v); + + return ReverseIteratorT(container.erase((++pos).base())); +} + } //namespace tools