1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-11 08:23:43 +00:00

Conversion can be a separate step.

This commit is contained in:
Thomas Harte 2023-06-12 15:34:44 -04:00
parent 8a831b1409
commit 05d2e78f80

View File

@ -11,18 +11,10 @@
namespace Dispatcher {
/// The unity function; converts n directly to n.
struct UnitConverter {
constexpr int operator ()(int n) {
return n;
}
};
template <int max, typename SequencerT, typename ConverterT = UnitConverter>
template <int max, typename SequencerT>
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.
/// Perform @c target.perform<n>() for the input range `start <= n < end`.
template <typename... Args>
void dispatch(SequencerT &target, int start, int end, Args&&... args) {
@ -53,7 +45,7 @@ private:
if constexpr (n < max) { \
if(use_end && end == n) return; \
} \
target.template perform<ConverterT()(n)>(args...); \
target.template perform<n>(args...); \
} \
[[fallthrough]];