fixed const-casting in erase_if(foa::table&,...)

This commit is contained in:
joaquintides
2023-03-25 18:50:25 +01:00
parent 8dbe380d6c
commit 40c5c6907a

View File

@ -422,10 +422,16 @@ public:
template<typename Predicate>
friend std::size_t erase_if(table& x,Predicate& pr)
{
using value_reference=typename std::conditional<
std::is_same<key_type,value_type>::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<const value_type&>(type_policy::value_from(*p)))){
if(pr(const_cast<value_reference>(type_policy::value_from(*p)))){
x.super::erase(pg,n,p);
}
});