Allow non-const constructors, destructors, and finally callbacks in ecs::container
All checks were successful
Run tests / Run tests (push) Successful in 7m6s

This commit is contained in:
Nikita Lisitsa 2026-08-13 15:01:03 +03:00
parent 091c467d2b
commit 1f7d9e278f

View file

@ -726,9 +726,10 @@ namespace psemek::ecs
auto id = next_constructor_id_++;
auto constructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback {
return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set<util::uuid> const & attached_components, util::hash_set<util::uuid> const & detached_components, bool force){
auto constructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback
{
return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set<util::uuid> const & attached_components, util::hash_set<util::uuid> const & detached_components, bool force) mutable
{
bool const invoke = force
|| (detail::contains_helper<Components>::contains(attached_components) || ...)
|| (detail::contains_helper<Components>::contains_without(detached_components) || ...)
@ -764,8 +765,10 @@ namespace psemek::ecs
auto id = next_destructor_id_++;
auto destructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback {
return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set<util::uuid> const & attached_components, util::hash_set<util::uuid> const & detached_components, bool force){
auto destructor_factory = [function = std::move(function)](std::vector<std::uint32_t> const & column_indices) -> detail::table_callback
{
return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set<util::uuid> const & attached_components, util::hash_set<util::uuid> const & detached_components, bool force) mutable
{
bool const invoke = force
|| (detail::contains_helper<Components>::contains_without(attached_components) || ...)
|| (detail::contains_helper<Components>::contains(detached_components) || ...)
@ -800,7 +803,7 @@ namespace psemek::ecs
}
else
{
wrapper = [function = std::move(function)](ecs::container &){ function(); };
wrapper = [function = std::move(function)](ecs::container &) mutable { function(); };
}
if (method_recursion_depth_ == 0)