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:

Qt Code:
  1. std::vector<int> it;
  2. // some code that fill "it" vector
  3.  
  4. std::vector<int *> iter;
  5. for(int i=0; i<it.size(); i++)
  6. {
  7. iter.push_back(&it(i));
  8. }
  9.  
  10. int sweek = 0;
  11. int dup=0;
  12.  
  13. // And now call the function which definition is:
  14. void matrixRecursion()
  15. {
  16. int start = sweek;
  17. int end = matrix[sweek];
  18.  
  19. for(it(start); it(start)<end; it(start)++)
  20. {
  21. if(sweek < it.size()-1)
  22. {
  23. sweek++;
  24. matrixRecursion();
  25. }
  26. else
  27. {
  28. for(int t=0; t<it.size(); t++)
  29. {
  30. dup += nIndex[*iter[t]];
  31. }
  32. }
  33. }
  34. }
To copy to clipboard, switch view to plain text mode 
For example lets say `it.size()` is 3. Then if everything would work as I expect the result should be like that:

Qt Code:
  1. for(int i=0; i<matrix[0]; i++)
  2. {
  3. for(int j=0; j<matrix[1]; j++)
  4. {
  5. for(int k=0; k<matrix[2]; k++)
  6. {
  7. dup += nIndex[i] + nIndex[j] + nIndex[k];
  8. }
  9. }
  10. }
To copy to clipboard, switch view to plain text mode