title: How to visualize a column order matrix with natvis like a 2d array
body: <p>I have a struct</p>
  <pre><code>struct Matrix2d
  {
      // Column first ordered elements
      vector&lt;int&gt; m_elements;
      int m_numRows;
      int m_numCols;
  };
  </code></pre>
  <p>m_elements stores {0, 1, 2, 3, 4, 5, 6, 7, 8} to represent the 2d matrix</p>
  <pre><code>0, 3, 6
  1, 4, 7
  2, 5, 8
  </code></pre>
  <p>I want to display this like below:
  <a href="https://i.stack.imgur.com/U4uRY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U4uRY.png" alt="enter image description here" /></a></p>
  <p>Using ArrayItems feature in Natvis, I am able to come down with:
  <a href="https://i.stack.imgur.com/nyooU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nyooU.png" alt="enter image description here" /></a></p>
  <p>Using natvis code:</p>
  <pre><code>  &lt;Type Name=&quot;Matrix2d&quot;&gt;
      &lt;Expand&gt;
        &lt;ArrayItems&gt;
          &lt;Direction&gt;Backward&lt;/Direction&gt;
          &lt;Rank&gt;2&lt;/Rank&gt;
          &lt;Size&gt;$i==0?m_numRows:m_numCols&lt;/Size&gt;
          &lt;ValuePointer&gt;&amp;amp;m_elements[0]&lt;/ValuePointer&gt;
        &lt;/ArrayItems&gt;
      &lt;/Expand&gt;
    &lt;/Type&gt;
  </code></pre>
  <p>But this is really ugly and I'd rather have each row be a single item than each element being an item, like how array2d is visualized.</p>
  <p>How would you write the code in Natvis such that Matrix2d can be visualized in such way?</p>