From e433a1fc67500ab6bc03c302c01304fd45c72d0e Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 27 Sep 2022 13:01:41 +0200 Subject: Added index, count vars to c_erase_if() + improved docs. --- include/stc/ccommon.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index c6ec4529..2e84633c 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -280,10 +280,13 @@ STC_INLINE void crange_next(crange_iter* it) } while (0) #define c_erase_if(it, C, cnt, pred) do { \ + size_t index = 0, count = 0; \ C##_iter it = C##_begin(&cnt); \ - while (it.ref) \ - if (pred) it = C##_erase_at(&cnt, it); \ + while (it.ref) { \ + if (pred) it = C##_erase_at(&cnt, it), ++count; \ else C##_next(&it); \ + ++index; \ + } \ } while (0) #endif // CCOMMON_H_INCLUDED -- cgit v1.2.3