meta: drop meta op cfind, use unused param value to pass constness around

This commit is contained in:
skypjack
2023-07-19 10:21:08 +02:00
committed by Michele Caini
parent 09f7814503
commit f775d3be67
2 changed files with 8 additions and 9 deletions

View File

@@ -167,15 +167,15 @@ struct basic_meta_associative_container_traits {
break;
case operation::find:
if(key->allow_cast<const typename Type::key_type &>()) {
if(value) {
*it = iterator{ctx, std::bool_constant<key_only>{}, const_cast<Type *>(cont)->find(key->cast<const typename Type::key_type &>())};
} else {
*it = iterator{ctx, std::bool_constant<key_only>{}, cont->find(key->cast<const typename Type::key_type &>())};
}
return true;
}
break;
case operation::cfind:
if(key->allow_cast<const typename Type::key_type &>()) {
*it = iterator{ctx, std::bool_constant<key_only>{}, cont->find(key->cast<const typename Type::key_type &>())};
return true;
}
break;
}

View File

@@ -56,8 +56,7 @@ enum class meta_associative_container_operation {
cend,
insert,
erase,
find,
cfind
find
};
} // namespace internal
@@ -2043,7 +2042,7 @@ inline meta_associative_container::size_type meta_associative_container::erase(m
*/
[[nodiscard]] inline meta_associative_container::iterator meta_associative_container::find(meta_any key) {
iterator it{};
vtable(storage.policy() == any_policy::cref ? operation::cfind : operation::find, *ctx, std::as_const(storage).data(), &key, nullptr, &it);
vtable(operation::find, *ctx, std::as_const(storage).data(), &key, storage.policy() == any_policy::cref ? nullptr : this, &it);
return it;
}