I'm trying to do some partial specialization stuff. I have a tuple
, and I want to iterate from a certain element index to the first tuple index, accumulating a value from each type in the tuple
. This would seem to be a simple matter of using a recursive template instantiation.
The problem is, I can't seem to get the recursion to work. In order to stop the recursion, I need to partially specialize the template function at tuple index 0. That seemed simple enough, but it's not working.
Note: I've removed the actual tuple
stuff from the example, as it's irrelevant; it's the template specialization that's not working.
template<int Index, typename Tpl>
size_t CalcInterleaveByteOffset(const Tpl &t)
{
size_t prevOffset = CalcInterleaveByteOffset<Index - 1>(t);
return prevOffset + sizeof(Tpl);
}
template<typename Tpl>
size_t CalcInterleaveByteOffset<0, Tpl>(const Tpl &t)
{
return 0;
}
GCC simply says that this kind of specialization is not allowed. Is that true? Is there some other way to handle this sort of thing?