From e893b0c531110546abf2d2677c1144ea3e290a3d Mon Sep 17 00:00:00 2001 From: ITHelpDec <34002836+ITHelpDec@users.noreply.github.com> Date: Sat, 27 May 2023 00:19:04 +0100 Subject: [PATCH 1/2] find_entry_for() const -> find_entry_for() - current function returns a mismatch of iterators (const vs non-const) No viable conversion from returned value of type.... 'std::__list_const_iterator, void *>' ...to function return type... 'ts::map::bucket_type::bucket_iterator' ...(aka '__list_iterator, void *>') - a better solution would be to preserve const-ness, but this will do for now --- listings/listing_6.11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listings/listing_6.11.cpp b/listings/listing_6.11.cpp index ed8fac3..e114068 100644 --- a/listings/listing_6.11.cpp +++ b/listings/listing_6.11.cpp @@ -20,7 +20,7 @@ class threadsafe_lookup_table bucket_data data; mutable std::shared_mutex mutex; - bucket_iterator find_entry_for(Key const& key) const + bucket_iterator find_entry_for(Key const& key) { return std::find_if(data.begin(),data.end(), [&](bucket_value const& item) From 14a87fc19385f934443d92eee28067299043c5c3 Mon Sep 17 00:00:00 2001 From: ITHelpDec <34002836+ITHelpDec@users.noreply.github.com> Date: Sat, 27 May 2023 11:12:07 +0100 Subject: [PATCH 2/2] `.value_for(...) const` -> `.value_for(...)` - consider removing `const` to allow programme to compile - 'this' argument to member function 'find_entry_for' has type... - 'const ts::map::bucket_type', ... - ...but function is not marked const --- listings/listing_6.11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listings/listing_6.11.cpp b/listings/listing_6.11.cpp index e114068..1bb1029 100644 --- a/listings/listing_6.11.cpp +++ b/listings/listing_6.11.cpp @@ -27,7 +27,7 @@ class threadsafe_lookup_table {return item.first==key;}); } public: - Value value_for(Key const& key,Value const& default_value) const + Value value_for(Key const& key,Value const& default_value) { std::shared_lock lock(mutex); bucket_iterator const found_entry=find_entry_for(key);