Loops Over Loops

Problem statement: Loop over a variable number of loops. I.e., we want to search a parameter space and therefore want to loop over multiple loops. The number of loops is variable. The initial approach goes like this: for (p1=1; p1<=10; ++p1) for (p2=1; p2<=10; ++p2) for (p3=1; p3<=10; ++p3) for (p4=1; p4<=10; ++p4) do_something(); It also might involve only two loops, i.e., p1 and p2 , or even…