Jelajahi Sumber

emitter: extra allocator check when moving

Michele Caini 3 tahun lalu
induk
melakukan
3925fc6124
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 5 1
      src/entt/signal/emitter.hpp

+ 5 - 1
src/entt/signal/emitter.hpp

@@ -76,7 +76,9 @@ public:
      * @param allocator The allocator to use.
      */
     emitter(emitter &&other, const allocator_type &allocator) noexcept
-        : handlers{container_type{std::move(other.handlers.first()), allocator}, allocator} {}
+        : handlers{container_type{std::move(other.handlers.first()), allocator}, allocator} {
+        ENTT_ASSERT(alloc_traits::is_always_equal::value || handlers.second() == other.handlers.second(), "Copying an emitter is not allowed");
+    }
 
     /**
      * @brief Move assignment operator.
@@ -84,6 +86,8 @@ public:
      * @return This dispatcher.
      */
     emitter &operator=(emitter &&other) noexcept {
+        ENTT_ASSERT(alloc_traits::is_always_equal::value || handlers.second() == other.handlers.second(), "Copying an emitter is not allowed");
+
         handlers = std::move(other.handlers);
         return *this;
     }