From 8860962e09fabd0c642b0156c51340a9f298e7db Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Nov 2022 09:46:53 +0100 Subject: [PATCH] util/IntrusiveHashSet: make several methods `const` --- src/util/IntrusiveHashSet.hxx | 6 +++--- test/util/TestIntrusiveHashSet.cxx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/IntrusiveHashSet.hxx b/src/util/IntrusiveHashSet.hxx index 2766a5915..dc10674c9 100644 --- a/src/util/IntrusiveHashSet.hxx +++ b/src/util/IntrusiveHashSet.hxx @@ -155,12 +155,12 @@ public: } [[nodiscard]] - constexpr const key_equal key_eq() const noexcept { + constexpr const key_equal &key_eq() const noexcept { return equal; } [[nodiscard]] - constexpr bool empty() noexcept { + constexpr bool empty() const noexcept { if constexpr (constant_time_size) return size() == 0; else @@ -170,7 +170,7 @@ public: } [[nodiscard]] - constexpr size_type size() noexcept { + constexpr size_type size() const noexcept { if constexpr (constant_time_size) return counter; else diff --git a/test/util/TestIntrusiveHashSet.cxx b/test/util/TestIntrusiveHashSet.cxx index 4e2c6770e..69748fbb2 100644 --- a/test/util/TestIntrusiveHashSet.cxx +++ b/test/util/TestIntrusiveHashSet.cxx @@ -41,18 +41,18 @@ struct IntItem final : IntrusiveHashSetHook { IntItem(int _value) noexcept:value(_value) {} struct Hash { - constexpr std::size_t operator()(const IntItem &i) noexcept { + constexpr std::size_t operator()(const IntItem &i) const noexcept { return i.value; } - constexpr std::size_t operator()(int i) noexcept { + constexpr std::size_t operator()(int i) const noexcept { return i; } }; struct Equal { constexpr bool operator()(const IntItem &a, - const IntItem &b) noexcept { + const IntItem &b) const noexcept { return a.value == b.value; } };