Просмотр исходного кода

sigh/dispatcher: use allocator<void>

Michele Caini 3 лет назад
Родитель
Сommit
80015e83d4

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

@@ -38,7 +38,7 @@ class dispatcher_handler final: public basic_dispatcher_handler {
     static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Invalid type");
 
     using alloc_traits = std::allocator_traits<Allocator>;
-    using signal_type = sigh<void(Type &), typename alloc_traits::template rebind_alloc<void (*)(Type &)>>;
+    using signal_type = sigh<void(Type &), Allocator>;
     using container_type = std::vector<Type, typename alloc_traits::template rebind_alloc<Type>>;
 
 public:
@@ -67,8 +67,7 @@ public:
     }
 
     [[nodiscard]] auto bucket() ENTT_NOEXCEPT {
-        using sink_type = typename sigh<void(Type &)>::sink_type;
-        return sink_type{signal};
+        return typename signal_type::sink_type{signal};
     }
 
     void trigger(Type event) {

+ 2 - 2
src/entt/signal/fwd.hpp

@@ -8,7 +8,7 @@ namespace entt {
 template<typename>
 class delegate;
 
-template<typename = std::allocator<char>>
+template<typename = std::allocator<void>>
 class basic_dispatcher;
 
 template<typename>
@@ -21,7 +21,7 @@ struct scoped_connection;
 template<typename>
 class sink;
 
-template<typename Type, typename = std::allocator<Type *>>
+template<typename Type, typename = std::allocator<void>>
 class sigh;
 
 /*! @brief Alias declaration for the most common use case. */

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

@@ -57,7 +57,6 @@ class sigh<Ret(Args...), Allocator> {
     friend class sink<sigh<Ret(Args...), Allocator>>;
 
     using alloc_traits = std::allocator_traits<Allocator>;
-    static_assert(std::is_same_v<typename alloc_traits::value_type, Ret (*)(Args...)>, "Invalid value type");
     using container_type = std::vector<delegate<Ret(Args...)>, typename alloc_traits::template rebind_alloc<delegate<Ret(Args...)>>>;
 
 public:

+ 1 - 1
test/entt/signal/dispatcher.cpp

@@ -187,7 +187,7 @@ TEST(Dispatcher, NamedQueue) {
 }
 
 TEST(Dispatcher, CustomAllocator) {
-    std::allocator<char> allocator;
+    std::allocator<void> allocator;
     entt::dispatcher dispatcher{allocator};
 
     ASSERT_EQ(dispatcher.get_allocator(), allocator);