Function invoke


#include <src/entt/entity/helper.hpp>

template <auto Member, typename Entity = entity>
void invoke(basic_registry< Entity > &reg, const Entity entt)


Helper to create a listener that directly invokes a member function.

Template Parameters

Member - Member function to invoke on a component of the given type.

Entity - A valid entity type (see entt_traits for more details).


reg - A registry that contains the given entity and its components.

entt - Entity from which to get the component.

Mentioned in

  • Entity Component System / Invoke


Lines 118-124 in src/entt/entity/helper.hpp.

template<auto Member, typename Entity = entity>
void invoke(basic_registry<Entity> &reg, const Entity entt) {
    static_assert(std::is_member_function_pointer_v<decltype(Member)>, "Invalid pointer to non-static member function");
    delegate<void(basic_registry<Entity> &, const Entity)> func;
    func.template connect<Member>(reg.template get<member_class_t<decltype(Member)>>(entt));
    func(reg, entt);

Add Discussion

Log in to comment