mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Tidy up; forward construction arguments.
This commit is contained in:
parent
4e12d5a70a
commit
c0547f6e14
@ -23,20 +23,21 @@ struct Dispatcher {
|
||||
|
||||
/// Perform @c target.perform<n>() for the input range `start <= n < end`;
|
||||
/// @c ConverterT()(n) will be applied to each individual step before it becomes the relevant template argument.
|
||||
void dispatch(SequencerT &target, int start, int end) {
|
||||
template <typename... Args>
|
||||
void dispatch(SequencerT &target, int start, int end, Args&&... args) {
|
||||
|
||||
// Minor optimisation: do a comparison with end once outside the loop and if it implies so
|
||||
// then do no further comparisons within the loop. This is somewhat targetted at expected
|
||||
// use cases.
|
||||
if(end < max) {
|
||||
dispatch<true>(target, start, end);
|
||||
dispatch<true>(target, start, end, args...);
|
||||
} else {
|
||||
dispatch<false>(target, start, end);
|
||||
dispatch<false>(target, start, end, args...);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template <bool use_end> void dispatch(SequencerT &target, int start, int end) {
|
||||
template <bool use_end, typename... Args> void dispatch(SequencerT &target, int start, int end, Args&&... args) {
|
||||
static_assert(max < 2048);
|
||||
|
||||
// Yes, macros, yuck. But I want an actual switch statement for the dispatch to start
|
||||
@ -52,7 +53,7 @@ private:
|
||||
if constexpr (n < max) { \
|
||||
if(use_end && end == n) return; \
|
||||
} \
|
||||
target.template perform<ConverterT()(n)>(); \
|
||||
target.template perform<ConverterT()(n)>(args...); \
|
||||
} \
|
||||
[[fallthrough]];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user