Add static_assert to notify when a function is not invocable in ecs::container::apply & batch_apply
This commit is contained in:
parent
eb87f1ea20
commit
08b14ded93
2 changed files with 18 additions and 0 deletions
|
|
@ -451,6 +451,7 @@ namespace psemek::ecs
|
|||
query_cache container::apply(Function && function, query_cache cache)
|
||||
{
|
||||
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
|
||||
static_assert(detail::invocable<Function, Components...>, "function is not invocable with these components");
|
||||
|
||||
if (!cache)
|
||||
cache = this->cache<Components...>();
|
||||
|
|
@ -495,6 +496,7 @@ namespace psemek::ecs
|
|||
query_cache container::batch_apply(Function && function, query_cache cache)
|
||||
{
|
||||
static_assert(detail::all_different_types_v<std::remove_const_t<Components>...>, "all component types must be different");
|
||||
static_assert(detail::batch_invocable<Function, Components...>, "function is not batch-invocable with these components");
|
||||
|
||||
if (!cache)
|
||||
cache = this->cache<Components...>();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@ namespace psemek::ecs
|
|||
namespace psemek::ecs::detail
|
||||
{
|
||||
|
||||
template <typename Function, typename ... Components>
|
||||
constexpr bool invocable = false
|
||||
|| std::invocable<Function, container &, handle, Components & ...>
|
||||
|| std::invocable<Function, container &, Components & ...>
|
||||
|| std::invocable<Function, handle, Components & ...>
|
||||
|| std::invocable<Function, Components & ...>
|
||||
;
|
||||
|
||||
template <typename Function, typename ... Components>
|
||||
void invoke(Function && function, container & parent, handle const & handle, Components & ... components)
|
||||
{
|
||||
|
|
@ -36,6 +44,14 @@ namespace psemek::ecs::detail
|
|||
}
|
||||
}
|
||||
|
||||
template <typename Function, typename ... Components>
|
||||
constexpr bool batch_invocable = false
|
||||
|| std::invocable<Function, container &, util::span<handle const>, util::span<Components> ...>
|
||||
|| std::invocable<Function, container &, util::span<Components> ...>
|
||||
|| std::invocable<Function, util::span<handle const>, util::span<Components> ...>
|
||||
|| std::invocable<Function, util::span<Components> ...>
|
||||
;
|
||||
|
||||
template <typename Function, typename ... Components>
|
||||
void batch_invoke(Function && function, container & parent, std::size_t count, handle const * handles, Components * ... components)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue