util/IntrusiveForwardList: push_{front,back}() returns iterator

This commit is contained in:
Max Kellermann 2023-09-21 13:14:16 +02:00 committed by Max Kellermann
parent 64647edbe1
commit 78d28063c4
1 changed files with 6 additions and 2 deletions

View File

@ -368,7 +368,7 @@ public:
return {&ToNode(t)}; return {&ToNode(t)};
} }
void push_front(reference t) noexcept { iterator push_front(reference t) noexcept {
auto &new_node = ToNode(t); auto &new_node = ToNode(t);
if constexpr (options.cache_last) if constexpr (options.cache_last)
@ -378,9 +378,11 @@ public:
new_node.next = head.next; new_node.next = head.next;
head.next = &new_node; head.next = &new_node;
++counter; ++counter;
return iterator_to(t);
} }
void push_back(reference t) noexcept iterator push_back(reference t) noexcept
requires(options.cache_last) { requires(options.cache_last) {
auto &new_node = ToNode(t); auto &new_node = ToNode(t);
new_node.next = nullptr; new_node.next = nullptr;
@ -388,6 +390,8 @@ public:
last_cache.value = &new_node; last_cache.value = &new_node;
++counter; ++counter;
return iterator_to(t);
} }
static iterator insert_after(iterator pos, reference t) noexcept static iterator insert_after(iterator pos, reference t) noexcept