From 40c5c6907a76d5bbd60cbfa495f8dc4ee2140828 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Sat, 25 Mar 2023 18:50:25 +0100 Subject: [PATCH] fixed const-casting in erase_if(foa::table&,...) --- include/boost/unordered/detail/foa/table.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/boost/unordered/detail/foa/table.hpp b/include/boost/unordered/detail/foa/table.hpp index 3145a14d..5713ccda 100644 --- a/include/boost/unordered/detail/foa/table.hpp +++ b/include/boost/unordered/detail/foa/table.hpp @@ -422,10 +422,16 @@ public: template friend std::size_t erase_if(table& x,Predicate& pr) { + using value_reference=typename std::conditional< + std::is_same::value, + const_reference, + reference + >::type; + std::size_t s=x.size(); x.for_all_elements( [&](group_type* pg,unsigned int n,element_type* p){ - if(pr(const_cast(type_policy::value_from(*p)))){ + if(pr(const_cast(type_policy::value_from(*p)))){ x.super::erase(pg,n,p); } });