mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-05 21:32:55 +00:00
Conversion can be a separate step.
This commit is contained in:
parent
8a831b1409
commit
05d2e78f80
@ -11,18 +11,10 @@
|
|||||||
|
|
||||||
namespace Dispatcher {
|
namespace Dispatcher {
|
||||||
|
|
||||||
/// The unity function; converts n directly to n.
|
template <int max, typename SequencerT>
|
||||||
struct UnitConverter {
|
|
||||||
constexpr int operator ()(int n) {
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <int max, typename SequencerT, typename ConverterT = UnitConverter>
|
|
||||||
struct Dispatcher {
|
struct Dispatcher {
|
||||||
|
|
||||||
/// Perform @c target.perform<n>() for the input range `start <= n < end`;
|
/// 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.
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void dispatch(SequencerT &target, int start, int end, Args&&... args) {
|
void dispatch(SequencerT &target, int start, int end, Args&&... args) {
|
||||||
|
|
||||||
@ -53,7 +45,7 @@ private:
|
|||||||
if constexpr (n < max) { \
|
if constexpr (n < max) { \
|
||||||
if(use_end && end == n) return; \
|
if(use_end && end == n) return; \
|
||||||
} \
|
} \
|
||||||
target.template perform<ConverterT()(n)>(args...); \
|
target.template perform<n>(args...); \
|
||||||
} \
|
} \
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user