Quellcode durchsuchen

emitter: extra allocator check when moving

Michele Caini vor 3 Jahren
Ursprung
Commit
3925fc6124
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  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.
      * @param allocator The allocator to use.
      */
      */
     emitter(emitter &&other, const allocator_type &allocator) noexcept
     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.
      * @brief Move assignment operator.
@@ -84,6 +86,8 @@ public:
      * @return This dispatcher.
      * @return This dispatcher.
      */
      */
     emitter &operator=(emitter &&other) noexcept {
     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);
         handlers = std::move(other.handlers);
         return *this;
         return *this;
     }
     }