Răsfoiți Sursa

dispatcher/emitter: constrained assure

Michele Caini 6 ani în urmă
părinte
comite
8451301a5a
3 a modificat fișierele cu 6 adăugiri și 2 ștergeri
  1. 3 1
      TODO
  2. 2 1
      src/entt/signal/dispatcher.hpp
  3. 1 0
      src/entt/signal/emitter.hpp

+ 3 - 1
TODO

@@ -25,9 +25,11 @@
 
 * Mission: get rid of named types
   - make it possible to use custom generators (eg for plugins)
-    * dispatcher, emitter, registry
+    * registry
+    * meta: use type_id, remove import, everything should work transparently
     * type_id_enabled and fallback on old-fashioned families otherwise
     * add discard pool functionality (+ test)
+  - use type_id also for groups, get rid of extent and subfunctions, is it possible?
   - reintroduce old-fashion family and add a new family-like thing with generators
   - families should be defined as out-of-class to guarantee the same identifiers for the same types
   - update doc: family, dispatcher, emitter, registry, meta, across boundaries

+ 2 - 1
src/entt/signal/dispatcher.hpp

@@ -81,6 +81,7 @@ class dispatcher {
 
     template<typename Event>
     pool_handler<Event> & assure() {
+        static_assert(std::is_same_v<Event, std::decay_t<Event>>);
         static std::size_t index{pools.size()};
 
         if(!(index < pools.size()) || pools[index]->id() != type_id_v<Event>) {
@@ -192,7 +193,7 @@ public:
                 cpool->clear();
             });
         } else {
-            (assure<std::decay_t<Event>>().clear(), ...);
+            (assure<Event>().clear(), ...);
         }
     }
 

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

@@ -120,6 +120,7 @@ class emitter {
 
     template<typename Event>
     const pool_handler<Event> & assure() const {
+        static_assert(std::is_same_v<Event, std::decay_t<Event>>);
         static std::size_t index{pools.size()};
 
         if(!(index < pools.size()) || pools[index]->id() != type_id_v<Event>) {