I'm working on a larger project to generalize template instantations and am struggling to cleanly linearize some indices using Boost MPL with C++03. It's easiest to show my problem with an example (pardon my poor pseudo code).
I have N vectors of arbitrary length. Say N is 3, and say they look like:
v0 = {1,2,3};
v1 = {4,5,6,7,8};
v2 = {9,10};
For each of those, I have an index stored in a separate vector, like:
vectorOfIndices = {0,4,1};
I want to convert those to an overall index by doing:
0*sizeof(v1)*sizeof(v2) + 4*sizeof(v2) + 1;
The meta function/class I'm looking for help defining is a generalization of this which should take in two template parameters, both of type mpl::vector (containing mpl::int_ entries). The first vector will contain a sequence of indices (vectorOfIndices above, but of length N) and the second vector will contain a list of lengths (lengths of v0, v1, v2...vN above). The result type should be an mpl::int_ that contains the overall index.