Template Function poet::dispatch(Functor&&, FirstParam&&, Rest&&…)
Defined in File dispatch.hpp
Function Documentation
-
template<typename Functor, typename FirstParam, typename ...Rest, std::enable_if_t<detail::is_dispatch_param_v<FirstParam>, int> = 0>
auto poet::dispatch(Functor &&functor, FirstParam &&first_param, Rest&&... rest) -> decltype(auto) Dispatches runtime integers to compile-time specializations.
Accepts leading
dispatch_paramarguments, followed by any remaining arguments, which are forwarded tofunctoruntouched.functoris invoked in whichever form it provides, with the value form preferred when both are viable (which is what makes a generic lambda work):functor(std::integral_constant<V, Value>{}..., args...): valuesfunctor.template operator()<Value...>(args...): template parameters
Warning
On a miss this overload is silent: it returns a default-constructed result (or nothing, for
void) and never callsfunctor. Prefix the call withpoet::throw_on_no_matchto get ano_match_errorinstead.- Parameters:
functor – The callable to specialize. Bound by reference, so a stateful functor’s mutations stay visible to the caller.
first_param – First
dispatch_param.rest – Further
dispatch_params (consecutive ones form a cartesian product), then the arguments to forward.