sigh: rebind allocator internally

This commit is contained in:
Michele Caini
2022-02-27 16:33:52 +01:00
parent bc9ee46b8f
commit bdb7763237
2 changed files with 6 additions and 3 deletions

View File

@@ -57,6 +57,9 @@ class sigh<Ret(Args...), Allocator> {
/*! @brief A sink is allowed to modify a signal. */
friend class sink<sigh<Ret(Args...), Allocator>>;
using alloc_traits = std::allocator_traits<Allocator>;
using container_type = std::vector<delegate<Ret(Args...)>, typename alloc_traits::template rebind_alloc<delegate<Ret(Args...)>>>;
public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
@@ -215,7 +218,7 @@ public:
}
private:
std::vector<delegate<Ret(Args...)>, Allocator> calls;
container_type calls;
};
/**

View File

@@ -1,8 +1,8 @@
#include <memory>
#include <utility>
#include <vector>
#include <gtest/gtest.h>
#include <entt/signal/sigh.hpp>
#include "../common/throwing_allocator.hpp"
struct sigh_listener {
static void f(int &v) {
@@ -531,7 +531,7 @@ TEST_F(SigH, UnboundMemberFunction) {
}
TEST_F(SigH, CustomAllocator) {
test::throwing_allocator<entt::delegate<void(int)>> allocator;
std::allocator<void (*)(int)> allocator;
auto test = [&](auto curr) {
ASSERT_EQ(curr.get_allocator(), allocator);