Browse Source

meta_any: unifying assignment operator

Michele Caini 6 years ago
parent
commit
96f793f91b
3 changed files with 20 additions and 31 deletions
  1. 0 1
      TODO
  2. 15 15
      src/entt/entity/actor.hpp
  3. 5 15
      src/entt/meta/meta.hpp

+ 0 - 1
TODO

@@ -26,7 +26,6 @@
 * ENTT_NAMED_TYPE -> ENTT_EXPORT and add also ENTT_EXPORT_WITH_NAME
 * meta: members+class as fake functions, is it possible?
 * meta: export implicitly generated named types if possible
-* welcome -ftime-trace to inspect compilation time
 * add meta support to registry:
   - entity for each component
   - opaque get

+ 15 - 15
src/entt/entity/actor.hpp

@@ -34,6 +34,21 @@ struct basic_actor {
         : entt{entt::null}, reg{nullptr}
     {}
 
+    /**
+     * @brief Move constructor.
+     *
+     * After actor move construction, instances that have been moved from are
+     * placed in a valid but unspecified state. It's highly discouraged to
+     * continue using them.
+     *
+     * @param other The instance to move from.
+     */
+    basic_actor(basic_actor &&other) ENTT_NOEXCEPT
+        : entt{other.entt}, reg{other.reg}
+    {
+        other.entt = null;
+    }
+
     /**
      * @brief Constructs an actor from a given registry.
      * @param ref An instance of the registry class.
@@ -60,21 +75,6 @@ struct basic_actor {
         }
     }
 
-    /**
-     * @brief Move constructor.
-     *
-     * After actor move construction, instances that have been moved from are
-     * placed in a valid but unspecified state. It's highly discouraged to
-     * continue using them.
-     *
-     * @param other The instance to move from.
-     */
-    basic_actor(basic_actor &&other) ENTT_NOEXCEPT
-        : entt{other.entt}, reg{other.reg}
-    {
-        other.entt = null;
-    }
-
     /**
      * @brief Move assignment operator.
      *

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

@@ -458,28 +458,18 @@ public:
      * @param type An instance of an object to use to initialize the container.
      * @return This meta any object.
      */
-    template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_any>>>
+    template<typename Type>
     meta_any & operator=(Type &&type) {
         return (*this = meta_any{std::forward<Type>(type)});
     }
 
     /**
-     * @brief Copy assignment operator.
-     * @param other The instance to assign.
-     * @return This meta any object.
-     */
-    meta_any & operator=(const meta_any &other) {
-        return (*this = meta_any{other});
-    }
-
-    /**
-     * @brief Move assignment operator.
-     * @param other The instance to assign.
+     * @brief Assignment operator.
+     * @param other The instance to assign from.
      * @return This meta any object.
      */
-    meta_any & operator=(meta_any &&other) {
-        meta_any any{std::move(other)};
-        swap(any, *this);
+    meta_any & operator=(meta_any other) {
+        swap(other, *this);
         return *this;
     }