util/IntrusiveForwardList: add non-static insert_after() implementation

This commit is contained in:
Max Kellermann 2023-09-13 08:54:48 +02:00 committed by Max Kellermann
parent df7ed27b78
commit 5c44082b77
1 changed files with 13 additions and 3 deletions

View File

@ -317,9 +317,10 @@ public:
++counter;
}
static iterator insert_after(iterator pos, reference t) noexcept {
// no counter update in this static method
static_assert(!constant_time_size);
static iterator insert_after(iterator pos, reference t) noexcept
requires(!constant_time_size) {
/* if we have no counter, then this method is allowed
to be static */
auto &pos_node = *pos.cursor;
auto &new_node = ToNode(t);
@ -328,6 +329,15 @@ public:
return &new_node;
}
iterator insert_after(iterator pos, reference t) noexcept {
auto &pos_node = *pos.cursor;
auto &new_node = ToNode(t);
new_node.next = pos_node.next;
pos_node.next = &new_node;
++counter;
return &new_node;
}
void erase_after(iterator pos) noexcept {
pos.cursor->next = pos.cursor->next->next;
--counter;