From e437cc4fafdf046842ba5e92932295a43dddcc01 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 9 Jun 2022 09:47:56 +0200 Subject: [PATCH] util/IntrusiveList: add size() --- src/util/IntrusiveList.hxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/IntrusiveList.hxx b/src/util/IntrusiveList.hxx index 2074220bc..84d874e47 100644 --- a/src/util/IntrusiveList.hxx +++ b/src/util/IntrusiveList.hxx @@ -207,6 +207,8 @@ class IntrusiveList { } public: + using size_type = std::size_t; + constexpr IntrusiveList() noexcept = default; IntrusiveList(IntrusiveList &&src) noexcept { @@ -255,6 +257,10 @@ public: return head.next == &head; } + constexpr size_type size() const noexcept { + return std::distance(begin(), end()); + } + void clear() noexcept { if constexpr (std::is_base_of::value) { /* for SafeLinkIntrusiveListHook, we need to