stl: std::allocate_shared

This commit is contained in:
skypjack
2026-04-20 18:31:05 +02:00
parent ea6b70f263
commit 8a1940c0fa
6 changed files with 10 additions and 9 deletions

View File

@@ -230,7 +230,7 @@ class basic_registry {
return static_cast<storage_type &>(*it->second);
}
typename pool_container_type::mapped_type cpool = std::allocate_shared<storage_type>(get_allocator(), get_allocator());
typename pool_container_type::mapped_type cpool = stl::allocate_shared<storage_type>(get_allocator(), get_allocator());
pools.emplace(id, cpool);
cpool->bind(*this);
@@ -1055,9 +1055,9 @@ public:
stl::shared_ptr<handler_type> handler{};
if constexpr(sizeof...(Owned) == 0u) {
handler = std::allocate_shared<handler_type>(get_allocator(), get_allocator(), stl::forward_as_tuple(assure<stl::remove_const_t<Get>>()...), stl::forward_as_tuple(assure<stl::remove_const_t<Exclude>>()...));
handler = stl::allocate_shared<handler_type>(get_allocator(), get_allocator(), stl::forward_as_tuple(assure<stl::remove_const_t<Get>>()...), stl::forward_as_tuple(assure<stl::remove_const_t<Exclude>>()...));
} else {
handler = std::allocate_shared<handler_type>(get_allocator(), stl::forward_as_tuple(assure<stl::remove_const_t<Owned>>()..., assure<stl::remove_const_t<Get>>()...), stl::forward_as_tuple(assure<stl::remove_const_t<Exclude>>()...));
handler = stl::allocate_shared<handler_type>(get_allocator(), stl::forward_as_tuple(assure<stl::remove_const_t<Owned>>()..., assure<stl::remove_const_t<Get>>()...), stl::forward_as_tuple(assure<stl::remove_const_t<Exclude>>()...));
ENTT_ASSERT(stl::all_of(groups.cbegin(), groups.cend(), [](const auto &data) { return !(data.second->owned(type_id<Owned>().hash()) || ...); }), "Conflicting groups");
}

View File

@@ -116,7 +116,7 @@ public:
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::constructible_from<Type, Args...>
static Service &emplace(stl::allocator_arg_t, auto alloc, Args &&...args) {
service = std::allocate_shared<Type>(alloc, stl::forward<Args>(args)...);
service = stl::allocate_shared<Type>(alloc, stl::forward<Args>(args)...);
return *service;
}

View File

@@ -221,7 +221,7 @@ public:
template<typename Type, typename... Args>
basic_process &then(Args &&...args) {
const auto &allocator = next.second();
return *(next.first() = std::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
return *(next.first() = stl::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
}
/**
@@ -234,7 +234,7 @@ public:
basic_process &then(Func func) {
const auto &allocator = next.second();
using process_type = internal::process_adaptor<delta_type, Func, allocator_type>;
return *(next.first() = std::allocate_shared<process_type>(allocator, allocator, stl::move(func)));
return *(next.first() = stl::allocate_shared<process_type>(allocator, allocator, stl::move(func)));
}
/**

View File

@@ -153,7 +153,7 @@ public:
template<typename Type, typename... Args>
type &attach(Args &&...args) {
const auto &allocator = handlers.second();
return *handlers.first().emplace_back(std::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
return *handlers.first().emplace_back(stl::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
}
/**
@@ -166,7 +166,7 @@ public:
type &attach(Func func) {
const auto &allocator = handlers.second();
using process_type = internal::process_adaptor<delta_type, Func, allocator_type>;
return *handlers.first().emplace_back(std::allocate_shared<process_type>(allocator, allocator, stl::move(func)));
return *handlers.first().emplace_back(stl::allocate_shared<process_type>(allocator, allocator, stl::move(func)));
}
/**

View File

@@ -120,7 +120,7 @@ class basic_dispatcher {
if(!ptr) {
const auto &allocator = get_allocator();
ptr = std::allocate_shared<handler_type<Type>>(allocator, allocator);
ptr = stl::allocate_shared<handler_type<Type>>(allocator, allocator);
}
return static_cast<handler_type<Type> &>(*ptr);

View File

@@ -9,6 +9,7 @@
namespace entt::stl {
using std::addressof;
using std::allocate_shared;
using std::allocator;
using std::allocator_arg;
using std::allocator_arg_t;