Browse Source

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

skypjack 2 years ago
parent
commit
f775d3be67
2 changed files with 7 additions and 8 deletions
  1. 5 5
      src/entt/meta/container.hpp
  2. 2 3
      src/entt/meta/meta.hpp

+ 5 - 5
src/entt/meta/container.hpp

@@ -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 &>())};
-                return true;
+                } else {
+                    *it = iterator{ctx, std::bool_constant<key_only>{}, cont->find(key->cast<const typename Type::key_type &>())};
             }
-            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;
         }
 

+ 2 - 3
src/entt/meta/meta.hpp

@@ -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;
 }