sigh/dispatcher: use allocator<void>

This commit is contained in:
Michele Caini
2022-04-20 16:40:19 +02:00
parent c37c35b52b
commit 80015e83d4
4 changed files with 5 additions and 7 deletions

View File

@@ -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) {

View File

@@ -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. */

View File

@@ -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:

View File

@@ -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);