Explorar el Código

dispatcher: assert within assure as it ought to be

Michele Caini hace 4 años
padre
commit
02f00e5339
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  1. 2 0
      src/entt/signal/dispatcher.hpp

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

@@ -129,6 +129,7 @@ class basic_dispatcher {
 
 
     template<typename Type>
     template<typename Type>
     [[nodiscard]] handler_type<Type> &assure(const id_type id) {
     [[nodiscard]] handler_type<Type> &assure(const id_type id) {
+        static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Non-decayed types not allowed");
         auto &&ptr = pools.first()[id];
         auto &&ptr = pools.first()[id];
 
 
         if(!ptr) {
         if(!ptr) {
@@ -141,6 +142,7 @@ class basic_dispatcher {
 
 
     template<typename Type>
     template<typename Type>
     [[nodiscard]] const handler_type<Type> *assure(const id_type id) const {
     [[nodiscard]] const handler_type<Type> *assure(const id_type id) const {
+        static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Non-decayed types not allowed");
         auto &container = pools.first();
         auto &container = pools.first();
 
 
         if(const auto it = container.find(id); it != container.end()) {
         if(const auto it = container.find(id); it != container.end()) {