
I've been trying out your new version, and I found that it was fairly easy to run out of indicies when using it repeatedy. Looking at the code, I think it should be possible to only generate one value per encoding. Basically my idea is that instead of using: friend sizer<VOLATILE> encode_value(encode_counter<Index>*); You could use: template<unsigned EncodingId, unsigned Index = 0> struct value_pair { typedef value_pair<EncodingId, Index+1> next; }; friend sizer<VOLATILE> encode_value(value_pair<EncodingId, Index>*); The existing compile time variable mechanism would just be used to generate the increasing EncodingId's - one per typedef. I included the next member so that the value_pair could be passed by type, replacing the existing Index parameter. Then whenever you currently use Index+1, you can use 'typename ValuePair::next'. I guess this is a little obvious, so sorry if you're already doing something like it. If it doesn't make sense I can put together an implementation. Daniel