Audacity 3.2.0
|
Namespaces | |
namespace | detail |
Functions | |
template<typename R = void, typename Types , class TupleLike , typename... Args> | |
auto | Dispatch (Head_t< Types > &object, const TupleLike &functions, Args &&... args) -> std::enable_if_t< TypeListCheck_v< Types >, R > |
template<typename R = void, typename Types , typename ... Functions> | |
auto | VDispatch (Head_t< Types > &object, const Functions &...functions) |
Variables | |
template<typename TypeList > | |
constexpr bool | TypeListCheck_v |
auto TypeSwitch::Dispatch | ( | Head_t< Types > & | object, |
const TupleLike & | functions, | ||
Args &&... | args | ||
) | -> std::enable_if_t<TypeListCheck_v<Types>, R> |
A variadic function taking any number of function objects, each taking
In the first case, the function object returns R or a type convertible to R.
In the second case, the next-function takes no arguments and returns likewise; the partial application of the curried function is then like the first case.
Calls the first in the sequence that accepts the actual type of the object (after any needed partial application).
If none accepts, do nothing and return R{} (or void when R is void).
If one of the curried functions invokes the no-argument function passed into it, the inner call invokes the next applicable function.
There is a compile-time check that all of the given functions are reachable (that is, all have correct signatures, and no function earlier in the list shadows a later function, by accepting a less derived class, without partial application).
A single Callable::OverloadSet might be used instead of this dispatch, when the next-functions are not used, but that would lose the advantage of the compile time checks.
R | returned by this function; each given function must return a type convertible to R |
Types | a non-empty TypeList; the first is polymorphic and a proper base of all other types; no type is a subclass of any type left of it; and either all are const-qualified, or none are |
TupleLike | deduced from argument |
Args... | extra arguments, passed to the functions |
object | determines the function to call by its run-time type |
functions | typically lambdas; see above |
Definition at line 313 of file TypeSwitch.h.
Referenced by anonymous_namespace{ProjectStatus.cpp}::Dispatcher::NewFieldRegistered(), and AudacityApp::OnExit().
auto TypeSwitch::VDispatch | ( | Head_t< Types > & | object, |
const Functions &... | functions | ||
) |
A variadic function taking any number of function objects, each taking
In the first case, the function object returns R or a type convertible to R.
In the second case, the next-function takes no arguments and returns likewise; the partial application of the curried function is then like the first case.
Calls the first in the sequence that accepts the actual type of the object (after any needed partial application).
If none accepts, do nothing and return R{} (or void when R is void).
If one of the curried functions invokes the no-argument function passed into it, the inner call invokes the next applicable function.
There is a compile-time check that all of the given functions are reachable (that is, all have correct signatures, and no function earlier in the list shadows a later function, by accepting a less derived class, without partial application).
A single Callable::OverloadSet might be used instead of this dispatch, when the next-functions are not used, but that would lose the advantage of the compile time checks.
R | returned by this function; each given function must return a type convertible to R |
Types | a non-empty TypeList; the first is polymorphic and a proper base of all other types; no type is a subclass of any type left of it; and either all are const-qualified, or none are |
TupleLike | deduced from argument |
Args... | extra arguments, passed to the functions |
object | determines the function to call by its run-time type |
functions | typically lambdas; see above |
Variadic overload of Dispatch; doesn't accept extra arguments
Definition at line 331 of file TypeSwitch.h.
|
constexpr |
Definition at line 259 of file TypeSwitch.h.