From 1f7d9e278fef00c2edf2fb54a7956d549b25604e Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 13 Aug 2026 15:01:03 +0300 Subject: [PATCH] Allow non-const constructors, destructors, and finally callbacks in ecs::container --- libs/ecs/include/psemek/ecs/container.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libs/ecs/include/psemek/ecs/container.hpp b/libs/ecs/include/psemek/ecs/container.hpp index 8ecd12e7..f39e59bf 100644 --- a/libs/ecs/include/psemek/ecs/container.hpp +++ b/libs/ecs/include/psemek/ecs/container.hpp @@ -726,9 +726,10 @@ namespace psemek::ecs auto id = next_constructor_id_++; - auto constructor_factory = [function = std::move(function)](std::vector const & column_indices) -> detail::table_callback { - return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set const & attached_components, util::hash_set const & detached_components, bool force){ - + auto constructor_factory = [function = std::move(function)](std::vector const & column_indices) -> detail::table_callback + { + return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set const & attached_components, util::hash_set const & detached_components, bool force) mutable + { bool const invoke = force || (detail::contains_helper::contains(attached_components) || ...) || (detail::contains_helper::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 const & column_indices) -> detail::table_callback { - return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set const & attached_components, util::hash_set const & detached_components, bool force){ + auto destructor_factory = [function = std::move(function)](std::vector const & column_indices) -> detail::table_callback + { + return [function, column_indices](container & container, detail::table & table, std::uint32_t row, util::hash_set const & attached_components, util::hash_set const & detached_components, bool force) mutable + { bool const invoke = force || (detail::contains_helper::contains_without(attached_components) || ...) || (detail::contains_helper::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)