title: No match for operator+ , and no match for vector construction call in c++
body: <p>I am trying to implement Matrix Addition using expression templates. I am facing some trouble. Here is my matrix code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;cassert&gt;
  
  template &lt;typename T&gt;
  class MatrixExpression {
    public:
      double operator[](size_t i) const { return static_cast&lt;T const&amp;&gt;(*this)[i];}
      size_t size()const { return static_cast&lt;T const&amp;&gt;(*this).size(); }
  };
  template&lt;typename T&gt;
  class Matrix:public MatrixExpression&lt;Matrix&lt;T&gt;&gt;
  {
      std::vector&lt;std::vector&lt;T&gt;&gt; mat;
  
      public:
      Matrix(std::size_t m, std::size_t n):mat(m,std::vector&lt;T&gt;(n)){}
  
  
  
      class Proxy
      {
          std::vector&lt;T&gt; vec;
          public:
          Proxy(std::vector&lt;T&gt; vec):vec(vec){ }
  
          T operator[](std::size_t i){ return vec[i];}
          //T &amp;operator[](std::size_t i){ return vec[i];}
          std::size_t size() const{ return vec.size(); }
      };
  
      Proxy operator[](std::size_t i) const { return Proxy(mat[i]); }
      //Proxy &amp;operator[](std::size_t i)      { return Proxy(mat[i]); }
      size_t size() const { return mat.size(); }
  
      Matrix(std::initializer_list&lt;std::initializer_list&lt;T&gt;&gt; lst)
      {
          int m=0,n=0;
          for(auto l:lst )
          {
              for(auto v:l)
              {
                  n++;
              }
              m++;
          }
          int i=0,j=0;
          mat(m,std::vector&lt;T&gt;(n));
          for(auto l:lst )
          {
              for(auto v:l)
              {
                  mat[i].push_back(v);
              }
              i++;
          }
      }
  
  
      Matrix(MatrixExpression&lt;T&gt; const&amp; matx):mat(matx.size(),std::vector&lt;T&gt;(matx[0].size))
      {
          for(int i=0;i&lt;matx.size();i++)
          {
              for(int j=0;j&lt;matx[0].size();j++)
              {
                  mat[i][j] = matx[i][j];
              }
          }
      }
  };
  
  template&lt;typename T, typename X, typename Y&gt;
  class MatrixSum:public MatrixExpression&lt;MatrixSum&lt;T,X,Y&gt;&gt;
  {
      X const&amp; x;
      Y const&amp; y;
  
      public:
      MatrixSum(X const&amp; x1, Y const&amp; y1):x(x1),y(y1){
          assert(x1.size()==y1.size());
          assert(x1[0].size()==y1[0].size());
      }
  
      class ProxySum
      {
          std::vector&lt;T&gt; vec1,vec2;
          public:
          ProxySum(std::vector&lt;T&gt; vec1,std::vector&lt;T&gt; vec2):vec1(vec1),vec2(vec2){ }
  
          T operator[](std::size_t i){ return vec1[i] + vec2[i];}
          //T &amp;operator[](std::size_t i){ return vec1[i] + vec2[i];}
          std::size_t size() const{ return vec1[0].size(); }
      };
      ProxySum operator[](std::size_t i) const { return ProxySum(x[i],y[i]); }
      //ProxySum &amp;operator[](std::size_t i){ return ProxySum(x[i],y[i]); }
      size_t size() const { return x.size(); } 
  
  };
  
  template&lt;typename T,typename X,typename Y&gt;
  MatrixSum&lt;T,X,Y&gt;
  operator+(X const&amp; x, Y const&amp; y)
  {
      return MatrixSum&lt;T,X,Y&gt;(x,y);
  }
  </code></pre>
  
  <p>I am getting two errors when using the Matrix class. First is the operator+ does not exist for Matrix (I used int from testing) even though I have implemented operator overloading for '+', and another error is in the second constructor for Matrix. It says that the call I have made for the constructor of mat variable is invalid.But vectors do have such constructor</p>