I would like to make recursion in for loop with access to following iterators independently.
I tried to do that, but it looks like nested loop doesn't update its parent iterator. I am not sure what's wrong here:
std::vector<int> it;
// some code that fill "it" vector
std::vector<int *> iter;
for(int i=0; i<it.size(); i++)
{
iter.push_back(&it(i));
}
int sweek = 0;
int dup=0;
// And now call the function which definition is:
void matrixRecursion()
{
int start = sweek;
int end = matrix[sweek];
for(it(start); it(start)<end; it(start)++)
{
if(sweek < it.size()-1)
{
sweek++;
matrixRecursion();
}
else
{
for(int t=0; t<it.size(); t++)
{
dup += nIndex[*iter[t]];
}
}
}
}
For example lets say it.size() is 3. Then if everything would work as I expect the result should be like that:
@Repeater - it(start) is my fault of course, sorry. I meant it[start]. And I mean by that just address of it[somevalue] which is pointing by iter[somevalue] and then I have easy access to each iterator by calling value under the pointed address, by calling *iter[somevalue]. But unfortunately it doesn't work. I don't know why. I suppose its some misunderstanding about recursion, I am not sure how it works. All iterations happen as I expect, just *iter[somevalue] which is called in last/deepest nested loop is not updating.