title: list initialization for a matrix class
body: <p>I am trying to write a matrix class for linear algebra calculations. I have almost finished writing what I wanted. but I have a little trouble in creating a constructor that uses list initialization to create a matrix.
  this is my class data members:</p>
  
  <pre><code>template &lt;typename T&gt;
  class Matx
  {
  private:
      // data members
      //rows and columns of matrix
      int rows, cols;
      //pointer to pointer to type T
      T** matrix;
  </code></pre>
  
  <p>and this is my code for initialization:</p>
  
  <pre><code>template &lt;typename T&gt;
  Matx&lt;T&gt;::Matx(T* ptM[], int m, int n) : rows(m), cols(n)
  {
      matrix = new T*[rows];
      for (int i = 0; i &lt; rows; i++)
          matrix[i] = new T[cols];
      for (int i = 0; i &lt; rows; i++)
          for (int j = 0; j &lt; cols; j++)
              matrix[i][j] = *(ptM[i] + j);
  }
  </code></pre>
  
  <p>in main:</p>
  
  <pre><code>double mat[][5] = { {5,5,-1,7,54},{4,-9,20,12,-6},{9,-18,-3,1,21},{ 61,-8,-10,3,13 },{ 29,-28,-1,4,14 } };
  double* pm[5];
  for (int i=0;i&lt;5;i++)
      pm[i]=mat[i];
  Matx&lt;double&gt; yourMat = Matx&lt;double&gt;(pm, 5,5);
  </code></pre>
  
  <p>but I think there is a better way to do it.
  what I want is to be able to initialize it like arrays. something like this:</p>
  
  <pre><code>Matx&lt;double&gt; yourMat = { {5,5,-1,7,54},{4,-9,20,12,-6},{9,-18,-3,1,21},{ 61,-8,-10,3,13 },{ 29,-28,-1,4,14 } };
  </code></pre>
  
  <p>Is it possible?</p>