Skip to content
Flecs v4.1
decl.hpp
Go to the documentation of this file.
1/**
2 * @file addons/cpp/mixins/event/decl.hpp
3 * @brief Event declarations.
4 */
5
6#pragma once
7
8
9
10namespace flecs {
11
12struct event_builder;
13template <typename E>
15namespace _ {
16
17// Utility to derive event type from function.
18template <typename Func, typename U = int>
20
21// Specialization for observer callbacks with a single argument.
22template <typename Func>
23struct event_from_func<Func, if_t< arity<Func>::value == 1>> {
24 using type = decay_t<first_arg_t<Func>>;
25};
26
27// Specialization for observer callbacks with an initial entity src argument.
28template <typename Func>
29struct event_from_func<Func, if_t< arity<Func>::value == 2>> {
30 using type = decay_t<second_arg_t<Func>>;
31};
32
33template <typename Func>
34using event_from_func_t = typename event_from_func<Func>::type;
35
36}
37}
Int to enum.
Definition component.hpp:18
Trait to get the number of arguments of a callable.
Typed event builder.
Definition builder.hpp:97
Untyped event builder.
Definition builder.hpp:91
enable_if_t< V, int > if_t
Convenience enable_if alias using int as default type.
Definition utils.hpp:168