util/IntrusiveList: pop_front() and pop_back() return reference

This commit is contained in:
Max Kellermann 2023-07-21 13:16:43 +02:00 committed by Max Kellermann
parent 62ee9a4d60
commit cc9d061e51

View File

@ -264,9 +264,7 @@ public:
void clear_and_dispose(Disposer<value_type> auto disposer) noexcept { void clear_and_dispose(Disposer<value_type> auto disposer) noexcept {
while (!empty()) { while (!empty()) {
auto *item = &front(); disposer(&pop_front());
pop_front();
disposer(item);
} }
} }
@ -302,15 +300,15 @@ public:
return *Cast(head.next); return *Cast(head.next);
} }
void pop_front() noexcept { reference pop_front() noexcept {
ToHook(front()).unlink();
--counter;
}
void pop_front_and_dispose(Disposer<value_type> auto disposer) noexcept {
auto &i = front(); auto &i = front();
ToHook(i).unlink(); ToHook(i).unlink();
--counter; --counter;
return i;
}
void pop_front_and_dispose(Disposer<value_type> auto disposer) noexcept {
auto &i = pop_front();
disposer(&i); disposer(&i);
} }
@ -319,7 +317,8 @@ public:
} }
void pop_back() noexcept { void pop_back() noexcept {
ToHook(back()).unlink(); auto &i = back();
ToHook(i).unlink();
--counter; --counter;
} }