Michele Caini 6 лет назад
Родитель
Сommit
30c7a64619
2 измененных файлов с 8 добавлено и 21 удалено
  1. 0 1
      TODO
  2. 8 20
      src/entt/meta/meta.hpp

+ 0 - 1
TODO

@@ -34,7 +34,6 @@
 * use [[nodiscard]] consistently for safety purposes
 
 * make meta work across boundaries
-  - ::prop: use meta_any as arguments rather than sfinae all around
   - extend and make factory::prop more flexible
   - entt::reflect<T>().type("foo"_hs, entt::as_property); or similar
   - forbid reflecting two times the same type

+ 8 - 20
src/entt/meta/meta.hpp

@@ -975,14 +975,11 @@ struct meta_ctor {
 
     /**
      * @brief Returns the property associated with a given key.
-     * @tparam Key Type of key to use to search for a property.
      * @param key The key to use to search for a property.
      * @return The property associated with the given key, if any.
      */
-    template<typename Key>
-    std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
-    prop(Key &&key) const ENTT_NOEXCEPT {
-        return internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
+    meta_prop prop(meta_any key) const ENTT_NOEXCEPT {
+        return internal::find_if([key = std::move(key)](auto *candidate) {
             return candidate->key() == key;
         }, node->prop);
     }
@@ -1178,14 +1175,11 @@ struct meta_data {
 
     /**
      * @brief Returns the property associated with a given key.
-     * @tparam Key Type of key to use to search for a property.
      * @param key The key to use to search for a property.
      * @return The property associated with the given key, if any.
      */
-    template<typename Key>
-    std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
-    prop(Key &&key) const ENTT_NOEXCEPT {
-        return internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
+    meta_prop prop(meta_any key) const ENTT_NOEXCEPT {
+        return internal::find_if([key = std::move(key)](auto *candidate) {
             return candidate->key() == key;
         }, node->prop);
     }
@@ -1314,14 +1308,11 @@ struct meta_func {
 
     /**
      * @brief Returns the property associated with a given key.
-     * @tparam Key Type of key to use to search for a property.
      * @param key The key to use to search for a property.
      * @return The property associated with the given key, if any.
      */
-    template<typename Key>
-    std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
-    prop(Key &&key) const ENTT_NOEXCEPT {
-        return internal::find_if([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
+    meta_prop prop(meta_any key) const ENTT_NOEXCEPT {
+        return internal::find_if([key = std::move(key)](auto *candidate) {
             return candidate->key() == key;
         }, node->prop);
     }
@@ -1711,14 +1702,11 @@ public:
      * means that the properties of the base classes will also be inspected, if
      * any.
      *
-     * @tparam Key Type of key to use to search for a property.
      * @param key The key to use to search for a property.
      * @return The property associated with the given key, if any.
      */
-    template<typename Key>
-    std::enable_if_t<!std::is_invocable_v<Key, meta_prop>, meta_prop>
-    prop(Key &&key) const ENTT_NOEXCEPT {
-        return internal::find_if<&internal::meta_type_node::prop>([key = meta_any{std::forward<Key>(key)}](auto *candidate) {
+    meta_prop prop(meta_any key) const ENTT_NOEXCEPT {
+        return internal::find_if<&internal::meta_type_node::prop>([key = std::move(key)](auto *candidate) {
             return candidate->key() == key;
         }, node);
     }