From a1adacdfe218d3e728cd4881b80962f1d337f4d4 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Sun, 19 Feb 2023 21:18:56 -0800 Subject: [PATCH] Refactor erase_on_exit to use a const_iterator so callsites can avoid a const cast --- include/boost/unordered/detail/foa.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index c18cab85..1f4d397d 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1509,7 +1509,7 @@ public: element_type extract(const_iterator pos) { BOOST_ASSERT(pos!=end()); - erase_on_exit e{*this,iterator{const_iterator_cast_tag{},pos}}; + erase_on_exit e{*this,pos}; (void)e; return std::move(*pos.p); } @@ -1599,14 +1599,14 @@ private: struct erase_on_exit { - erase_on_exit(table& x_,iterator it_):x{x_},it{it_}{} + erase_on_exit(table& x_,const_iterator it_):x{x_},it{it_}{} ~erase_on_exit(){if(!rollback_)x.erase(it);} void rollback(){rollback_=true;} - table& x; - iterator it; - bool rollback_=false; + table& x; + const_iterator it; + bool rollback_=false; }; Hash& h(){return hash_base::get();}