From 2d69c7a5ca6ef92ff4db3f9c702cfeb07f3f480b Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Thu, 18 Nov 2021 10:19:20 -0800 Subject: [PATCH 1/4] Add missing const-qualification of `operator==` for internal `optional` implementation --- include/boost/unordered/detail/implementation.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 5daf53ee..1352d462 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -827,13 +827,13 @@ namespace boost { T* operator->() { return value_.value_ptr(); } T const* operator->() const { return value_.value_ptr(); } - bool operator==(optional const& x) + bool operator==(optional const& x) const { return has_value_ ? x.has_value_ && value_.value() == x.value_.value() : !x.has_value_; } - bool operator!=(optional const& x) { return !((*this) == x); } + bool operator!=(optional const& x) const { return !((*this) == x); } void swap(optional& x) { From d0d4be9e351a16b74801210c49d654b49e6aa304 Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Thu, 18 Nov 2021 10:19:46 -0800 Subject: [PATCH 2/4] Add missing `operator==` overloads for direct `list_iterator` comparisons --- test/helpers/list.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/helpers/list.hpp b/test/helpers/list.hpp index d39c766e..3fddd6d3 100644 --- a/test/helpers/list.hpp +++ b/test/helpers/list.hpp @@ -113,6 +113,10 @@ namespace test { ptr_ = ptr_->next_; return tmp; } + + bool operator==(list_iterator y) const { return ptr_ == y.ptr_; } + bool operator!=(list_iterator y) const { return ptr_ != y.ptr_; } + bool operator==(const_iterator y) const { return ptr_ == y.ptr_; } bool operator!=(const_iterator y) const { return ptr_ != y.ptr_; } }; From dbba786a35f96c7825c715ea90481a9e8020fcc5 Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Thu, 18 Nov 2021 10:24:57 -0800 Subject: [PATCH 3/4] Add missing const-qualification for `operator==` member functions --- test/unordered/deduction_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unordered/deduction_tests.cpp b/test/unordered/deduction_tests.cpp index 673c0609..cffb0c1d 100644 --- a/test/unordered/deduction_tests.cpp +++ b/test/unordered/deduction_tests.cpp @@ -30,8 +30,8 @@ template struct test_allocator template test_allocator(test_allocator const&) {} T* allocate(std::size_t n) const { return (T*)malloc(sizeof(T) * n); } void deallocate(T* ptr, std::size_t) const { free(ptr); } - bool operator==(test_allocator const&) { return true; } - bool operator!=(test_allocator const&) { return false; } + bool operator==(test_allocator const&) const { return true; } + bool operator!=(test_allocator const&) const { return false; } }; #endif From 2e1ef850e3e42108edc7f7aae037a6bf6a41c3e9 Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Thu, 18 Nov 2021 10:25:44 -0800 Subject: [PATCH 4/4] Add const qualification to auto-generated allocator methods in test suite --- test/unordered/allocator_traits.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unordered/allocator_traits.cpp b/test/unordered/allocator_traits.cpp index 476205b7..0517fb97 100644 --- a/test/unordered/allocator_traits.cpp +++ b/test/unordered/allocator_traits.cpp @@ -65,9 +65,9 @@ { \ return (std::numeric_limits::max)(); \ } \ - bool operator==(name const&) { return true; } \ - bool operator!=(name const&) { return false; } \ -/**/ + bool operator==(name const&) const { return true; } \ + bool operator!=(name const&) const { return false; } \ + /**/ struct yes_type {