Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Increase type-infering functions to all possible event permutations #23

Merged
merged 3 commits into from
Sep 29, 2016

Conversation

geky
Copy link
Contributor

@geky geky commented Sep 28, 2016

EventQueue::event is now defined for the following overloads:

event(R (*)(A...),                                       C...);
event(F,                                                 C...);
event(const F,                                           C...);
event(volatile F,                                        C...);
event(const volatile F,                                  C...);
event(T *,                R (T::*)(A...),                C...);
event(const T *,          R (T::*)(A...) const,          C...);
event(volatile T *,       R (T::*)(A...) volatile,       C...);
event(const volatile T *, R (T::*)(A...) const volatile, C...);

This insures cleaner error messages when invalid types are used.

It should be noted that different types are used for the infered function parameters and the arguments supplied to event, this is important for inducing implicit casts.

Otherwise, deceptively confusing bugs can occur:

    void doit(unsigned value);
    queue.event(doit, 1); // Error - 1 is signed without implicit casts

With the stricter type inference on the convenience event function, it is trivial to determine the quantity of parameters present in a function type.

With the arity of the function type, we can determine which Event class must be generated entirely based on type inference. This is a huge benefit to the value of the convenience event functions and removes any lingering limitations on the event function usage.

EventQueue::event is now defined for the following overloads:
- event(R (*)(A...),                                       C...)
- event(F,                                                 C...)
- event(const F,                                           C...)
- event(volatile F,                                        C...)
- event(const volatile F,                                  C...)
- event(T *,                R (T::*)(A...),                C...)
- event(const T *,          R (T::*)(A...) const,          C...)
- event(volatile T *,       R (T::*)(A...) volatile,       C...)
- event(const volatile T *, R (T::*)(A...) const volatile, C...)

This insures cleaner error messages when invalid types are used.

It should be noted that different types are used for the infered
function parameters and the arguments supplied to event, this is
important for inducing implicit casts.

Otherwise, deceptively confusing bugs can occur:

    void doit(unsigned value);
    queue.event(doit, 1); // Error - 1 is signed without implicit casts
With the stricter type inference on the convenience event function,
it is trivial to determine the quantity of parameters present
in a function type.

With the arity of the function type, we can determine which Event class
must be generated entirely based on type inference. This is a huge
benefit to the value of the convenience event functions and removes
any lingering limitations on the event function usage.
@geky geky merged commit d6c5750 into master Sep 29, 2016
@geky geky deleted the event-inference branch September 29, 2016 00:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant