I have written the following basic Tuple template:
template
class Tuple;
template
struct TupleIndex
You do the exact same thing as you do with TupleIndexer, just at runtime.
Add a function like this to the Tuple class:
Head &operator[](unsigned i) {
return i ? ((Tuple&)*this)[i-1] : element;
}
and add a specialization for Tuple
:Head &operator[](unsigned i) {
assert(!i);
return i;
}
(You can't put the base case into Tuple<>, since you don't have a type to return that would be compatible with every possible caller.)