title: matrix class , variadic constructor
body: <p>I'm trying to create a simple matrix class, the point is that i'm using standard pointer to store the data .. and I don't know 2 things 
  how can i solve the problem of this constructor :</p>
  
  <pre><code>template&lt;typename data_type&gt;
  template &lt;typename ... Ts&gt;   
  constexpr Matrix&lt;data_type&gt;::Matrix(std::size_t row , 
                                      std::size_t col ,
                                      Ts&amp;&amp;... args     ) noexcept : row{row}, columns{col},
                                                                     data{ new data_type[row*col] },
  
  {
          std::size_t i =0;    
          assert(sizeof...(args) == row*columns );    
          data[i++] = (std::forward&lt;Ts&gt;(args)...);          
  }
  </code></pre>
  
  <p>i got the error : </p>
  
  <pre><code>In file included from matrixDrive.cpp:3:0:
  matrix.H: In constructor ‘constexpr Matrix&lt;U&gt;::Matrix(std::size_t, std::size_t, Ts&amp;&amp; ...)’:
  matrix.H:93:1: error: expected identifier before ‘{’ token
   {
   ^
  matrix.H: In instantiation of ‘constexpr Matrix&lt;U&gt;::Matrix(std::size_t, std::size_t, Ts&amp;&amp; ...) [with Ts = {double, double, double, double, double, double}; data_type = double; std::size_t = long unsigned int]’:
  matrixDrive.cpp:11:68:   required from here
  matrix.H:96:19: error: cannot convert ‘&lt;brace-enclosed initializer list&gt;’ to ‘double’ in assignment
           data[i++] = {std::forward&lt;Ts&gt;(args)...};
           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  matrixDrive.cpp: In function ‘int main()’:
  matrixDrive.cpp:13:3: error: expected ‘,’ or ‘;’ before ‘return’
     return 0;
     ^~~~~~
  </code></pre>
  
  <p>here the whole implementation:</p>
  
  <pre><code># include &lt;iostream&gt;
  # include &lt;utility&gt;
  # include &lt;iomanip&gt;
  # include &lt;vector&gt;
  # include &lt;exception&gt;
  # include &lt;iterator&gt;
  # include &lt;cassert&gt;
  
  template &lt;class U&gt; class Matrix ;
  
  template &lt;class U&gt;
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; , Matrix&lt;U&gt;&amp; );
  
  template &lt;class U&gt;
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; ,const Matrix&lt;U&gt;&amp; ); 
  
  
  //- class declararation
  //
  template &lt;typename data_type = double&gt;
  class Matrix {
  
     public:   
      //- friend function
      template &lt;class U&gt;
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; ,Matrix&lt;U&gt;&amp; ); 
  
      template &lt;class U&gt;
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; ,const Matrix&lt;U&gt;&amp; ); 
  
  
  
  
  
     public:
      constexpr Matrix(std::size_t r = 3 , std::size_t c = 3) noexcept;  
  
      constexpr Matrix(std::size_t r, std::size_t c, data_type val) noexcept;  
  
      template &lt;typename ... Ts&gt;   
      constexpr Matrix(std::size_t row , std::size_t col, Ts&amp;&amp;... args) noexcept;  
  
      virtual ~Matrix() noexcept ; 
  
  
      auto constexpr zeros() noexcept ;
  
      auto constexpr initialize(data_type) noexcept ;
  
      data_type&amp; operator()(std::size_t, std::size_t);  
  
  //-------
     private:   
  
        data_type *data     ;
        std::size_t row     ;
        std::size_t columns ;
  
        auto constexpr isAllocate() noexcept { return data != nullptr ; } 
  
  };
  
  // Matrix definition
  
  //- standard constructor
  template&lt;typename data_type&gt;
  constexpr Matrix&lt;data_type&gt;::Matrix(std::size_t r, std::size_t c) noexcept : row{r}, columns{c}, 
                                                                       data{new data_type[r*c]}
  {
        this-&gt;zeros();
  }
  
  
  template&lt;typename data_type&gt;
  constexpr Matrix&lt;data_type&gt;::Matrix(std::size_t r, std::size_t c, data_type val) noexcept : row{r}, columns{c}, 
                                                                                              data{new data_type[r*c]}
  {
        this-&gt;initialize(val);
  }  
  
  
  //--- construct by list of arguments
  template&lt;typename data_type&gt;
  template &lt;typename ... Ts&gt;   
  constexpr Matrix&lt;data_type&gt;::Matrix(std::size_t row , 
                                      std::size_t col ,
                                      Ts&amp;&amp;... args     ) noexcept : row{row}, columns{col},
                                                                     data{ new data_type[row*col] },
  
  {
          std::size_t i =0;    
          assert(sizeof...(args) == row*columns );    
          data[i++] = (std::forward&lt;Ts&gt;(args)...);          
  }
  
  
  // destructor
  template&lt;typename data_type&gt;
  Matrix&lt;data_type&gt;::~Matrix() noexcept 
  {
        if( isAllocate() )
              delete[] data; 
  }
  
  
  
  
  
  //----------------------------------------------------------------------------------------------------
  //
  
  template &lt;typename data_type&gt;
  auto constexpr Matrix&lt;data_type&gt;::zeros() noexcept {
     if(isAllocate())
       for(size_t i=0; i&lt; row*columns ; i++)
              data[i] = 0; 
  }
  
  
  template &lt;typename data_type&gt;
  auto constexpr Matrix&lt;data_type&gt;::initialize(data_type val) noexcept
  {
        if(isAllocate())
           for(size_t i=0 ; i &lt; row*columns; i++)
              data[i] = val ;
  }
  
  
  
  
  //-----------
  
  template &lt;typename data_type&gt;
  data_type&amp; Matrix&lt;data_type&gt;::operator()(std::size_t i, std::size_t j) { return data[(i-1) + row* (j-1)] ; }  
  
  
  // non member function 
  
  template &lt;class U&gt;
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out ,Matrix&lt;U&gt;&amp; mat)
  {
      for(std::size_t r = 1; r &lt; mat.row+1 ; r++)
      {
        for(std::size_t c = 1; c &lt; mat.columns+1 ; c++)
        {
            out &lt;&lt; mat(r,c) &lt;&lt; ' ' ;  
        }
        out &lt;&lt; "\n" ;
      }
  }
  
  template &lt;class U&gt;
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out , const Matrix&lt;U&gt;&amp; mat) 
  {
      for(std::size_t r = 1; r &lt; mat.row+1 ; r++)
      {
        for(std::size_t c = 1; c &lt; mat.columns+1 ; c++)
        {
            out &lt;&lt; mat(r,c) &lt;&lt; ' ';  
        }
        out &lt;&lt; "\n" ;
      }
  }
  </code></pre>
  
  <p>and the main function : </p>
  
  <pre><code># include &lt;iostream&gt;
  # include &lt;iomanip&gt;
  # include "matrix.H"
  
  using namespace std;
  
  int main() {
  
    Matrix&lt;double&gt; m1, m2(6,3);    
  
    Matrix&lt;double&gt; m3(3,2,1.12,2.434,3.546546,4.657,5.675675,6.542354)    
  
    return 0;    
  }
  </code></pre>
  
  <p>thanks in advance for your precious help! </p>