I'm using an array of pointer to function. I wrote the code like this since some of elements can not be expressed with function template.
extern void zero(); // isr 0 is defined somewhere else
void one() {
// isr 1
}
template <std::size_t N>
void Nth() {
// isr N
}
using func = void (*)();
constexpr func interrupt_vector[256] = {
&zero,
&one,
&Nth<2>,
&Nth<3>,
...
&Nth<254>,
&Nth<255>,
};
I've read about static table generation with variadic template, but those were about initializing the whole array.
How can I simplify the code?
@ Actually It's a part of interrupt vector. Since it should be called directly, I cannot use template specialization such as
template <>
void Nth<0>() {
zero();
}
@@ Edited the code. I think that cout things were confusing.