SYNOPSIS top
Creating and defining
Creating and defining
omni::delegate
types can get quite verbose when dealing with a function with multiple parameters. To alleviate this, you can use this helper macro to define an omni::delegate
with a number of parameters and a specific return type:int function0() { return 42; } int function3(int x, int y, int z) { return (x * y) / z; } int main(int argc, char* argv[]) { // omni::delegate<int> f0 = &function0; omni_delegate(int) f0 = &function0; // omni::delegate3<int, int, int, int> f3 = &function3; omni_delegate(int, int, int, int) f3 = &function3; std::cout << f3(f0(), f0(), f0()) << std::endl; return 0; }
DESCRIPTION top
This helper macro allows you to define an
So that you do not have to specify the specific event type, you can use the
You can even use the macro in
This helper macro allows you to define an
omni::event
of any parameter length without having to specify the specific omni::event
type. In other words, usually one would have to define an omni::event
with 2 parameter types by declaring it as such omni::event2
<void, int, int> additionally, one would have to define an omni::event
that takes 1 parameter as such omni::event1
<void, int> this is true for any of the omni::event
types up to 16 parameters.So that you do not have to specify the specific event type, you can use the
omni_event
helper macro to define the correct omni::event
type without having to be specific each time, reducing code and confusion.int function0() { return 42; } int function3(int x, int y, int z) { return (x * y) / z; } int main(int argc, char* argv[]) { // omni::event<int> f0(&function0); omni_event(int) f0(&function0); // omni::delegate3<int, int, int, int> f3 = &function3; omni_delegate(int, int, int, int) f3 = &function3; std::cout << f3(f0(), f0(), f0()) << std::endl; return 0; }
typedef
definitions:typedef omni_delegate(int, int, int, int) functor3; typedef omni_delegate(int) functor1; int function0() { return 42; } int function3(int x, int y, int z) { return (x * y) / z; } int main(int argc, char* argv[]) { functor1 f1 = &function1; functor3 f3 = &function3; std::cout << f3(f1(), f1(), f1()) << std::endl; return 0; }