From 83a648c1ea1ed71b767779ac604833bc2f4ef200 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sun, 30 Aug 2020 23:18:29 +0200 Subject: Added return iterators to clist_insert_after() and clist_erase_after(), conforming with std::forward_list. --- stc/clist.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/stc/clist.h b/stc/clist.h index 2dfbb2ac..153da566 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -115,13 +115,13 @@ clist_##tag##_push_n(clist_##tag *self, const clist_##tag##_input_t in[], size_t size); \ STC_API void \ clist_##tag##_pop_front(clist_##tag* self); \ - STC_API void \ + STC_API clist_##tag##_iter_t \ clist_##tag##_insert_after_v(clist_##tag* self, clist_##tag##_iter_t pos, Value value); \ - STC_INLINE void \ + STC_INLINE clist_##tag##_iter_t \ clist_##tag##_insert_after(clist_##tag* self, clist_##tag##_iter_t pos, RawValue rawValue) { \ - clist_##tag##_insert_after_v(self, pos, valueFromRaw(rawValue)); \ + return clist_##tag##_insert_after_v(self, pos, valueFromRaw(rawValue)); \ } \ - STC_API void \ + STC_API clist_##tag##_iter_t \ clist_##tag##_erase_after(clist_##tag* self, clist_##tag##_iter_t pos); \ STC_API void \ clist_##tag##_splice_front(clist_##tag* self, clist_##tag* other); \ @@ -189,14 +189,16 @@ _clist_erase_after(self, tag, self->last, valueDestroy); \ } \ \ - STC_API void \ + STC_API clist_##tag##_iter_t \ clist_##tag##_insert_after_v(clist_##tag* self, clist_##tag##_iter_t pos, Value value) { \ _clist_insert_after(self, tag, pos.item, value); \ if (!self->last || pos.item == self->last) self->last = entry; \ + pos.item = entry; return pos; \ } \ - STC_API void \ + STC_API clist_##tag##_iter_t \ clist_##tag##_erase_after(clist_##tag* self, clist_##tag##_iter_t pos) { \ _clist_erase_after(self, tag, pos.item, valueDestroy); \ + clist_##tag##_next(&pos); return pos; \ } \ \ STC_API void \ -- cgit v1.2.3