Make constructors & destructors operate on const components only in ecs

This commit is contained in:
Nikita Lisitsa 2024-01-30 21:56:52 +03:00
parent 802bb1a74d
commit 88677eb893

View file

@ -629,7 +629,7 @@ namespace psemek::ecs
{
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components ...>, Function>::type;
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components const ...>, Function>::type;
static_assert(invocable_type::value, "function is not invocable with these components");
@ -637,7 +637,7 @@ namespace psemek::ecs
cache->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){
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components ...>>::type apply_helper(container, table.entity_handles());
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components const ...>>::type apply_helper(container, table.entity_handles());
for (std::size_t i = 0; i < apply_helper.column_count; ++i)
apply_helper.pointers[i] = table.columns()[column_indices[i]]->data();
@ -655,7 +655,7 @@ namespace psemek::ecs
{
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components ...>, Function>::type;
using invocable_type = typename detail::filter_with<detail::invocable, std::tuple<Components const ...>, Function>::type;
static_assert(invocable_type::value, "function is not invocable with these components");
@ -663,7 +663,7 @@ namespace psemek::ecs
cache->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){
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components ...>>::type apply_helper(container, table.entity_handles());
typename detail::filter_with<detail::static_apply_helper, std::tuple<Components const ...>>::type apply_helper(container, table.entity_handles());
for (std::size_t i = 0; i < apply_helper.column_count; ++i)
apply_helper.pointers[i] = table.columns()[column_indices[i]]->data();