title: Clean ways to write multiple 'for' loops
body: <p>For an array with multiple dimensions, we usually need to write a <code>for</code> loop for each of its dimensions. For example:</p>
  
  <pre><code>vector&lt; vector&lt; vector&lt;int&gt; &gt; &gt; A;
  
  for (int k=0; k&lt;A.size(); k++)
  {
      for (int i=0; i&lt;A[k].size(); i++)
      {
          for (int j=0; j&lt;A[k][i].size(); j++)
          {
              do_something_on_A(A[k][i][j]);
          }
      }
  }
  
  double B[10][8][5];
  for (int k=0; k&lt;10; k++)
  {
      for (int i=0; i&lt;8; i++)
      {
          for (int j=0; j&lt;5; j++)
          {
              do_something_on_B(B[k][i][j]);
          }
      }
  }
  </code></pre>
  
  <p>You see this kind of <code>for-for-for</code> loops in our code frequently. How do I use macros to define the <code>for-for-for</code> loops so that I don't need to re-write this kind of code every time? Is there a better way to do this?</p>