title: C++ iterators - Deduce dimensionality
body: <p>I'm calculating the determinant of a matrix, the calculations and therefore a method is called depending on the dimensionality of the data, for example:</p>
  
  <pre><code>template&lt;int X, int Y&gt;
  float determinant(X, Y, std::vector&lt;Vector&gt; &amp;data)
  {
      // Determine the dimensionality of matrix data (x and y) 
  }
  </code></pre>
  
  <p>The problem that I am having is that in the class that calculates the PCA, which calls this function, only accepts an iterator: </p>
  
  <pre><code>class PCA { 
  
     public: 
  
        template&lt;typename T&gt; 
        PCA(T begin, T end)
        {
            // Determine the X and Y here
            float det = determinant(X, Y, ....); 
        }
  }; 
  </code></pre>
  
  <p>Now I am wondering whether or not it is possible to deduce the <code>X</code> and <code>Y</code> from the iterator that has been passed through PCA, rather than passing in two integer values. </p>
  
  <p>Any advice would be greatly appreciated </p>
  
  <p>EDIT:</p>
  
  <p>Apologises, my question was not clear.</p>
  
  <p>Basically, <code>typedef std::vector&lt;double&gt; Vector;</code> is used so therefore <code>std::vector&lt;Vector&gt; data;</code> would therefore be a vector of vectors.</p>
  
  <p>I sample this doing the following:</p>
  
  <p><code>std::vector&lt;Vector&gt; data1 = { {1, 2}, {3, 4}, {5, 6}, {8, 9} }; // 2x2</code> whereas when I want to add the following: <code>std::vector&lt;Vector&gt; data2 = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12} }; // 3x3</code> so obviously, when calculating the determinant there is a different calculation for this. </p>
  
  <p>I want to deduce that data1 is a 2x2 and data2 3x3 from the function without having to specifically pass these values in. </p>