title: How to write generic version of variadic template class that calculates sum of integers
body: <p>I came across the following code (below) on this site</p>
  
  <p><a href="https://www.modernescpp.com/index.php/c-insights-variadic-templates" rel="nofollow noreferrer">https://www.modernescpp.com/index.php/c-insights-variadic-templates</a></p>
  
  <p>But this declaration/definition works only with integers and I want to write a version that works with other types like float, double, std::strings and user defined types that overloads "+" operator. However I am struggling to write one.</p>
  
  <p>Please note that the mentioned site has variadic function template based solution that works with different datatypes including floating point types(not tried with user defined types yet). I am looking for a variadic template class based solution. This is purely for learning purpose.</p>
  
  <p>Can someone please help me to get this right?</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  template&lt;int...&gt;
  struct add;
  
  template&lt;&gt;
  struct add&lt;&gt;
  {
    static constexpr int value = 0;
  };
  
  template&lt;int i, int... tail&gt;
  struct add&lt;i, tail...&gt;
  {
    static constexpr int value = i + add&lt;tail...&gt;::value;
  };
  
  int main()
  {
      std::cout &lt;&lt; add&lt;1,2,3,4&gt;::value;
  }
  </code></pre>
  
  <p>I wrote this but got stuck</p>
  
  <pre><code>template&lt;typename ...&gt;
  struct add;
  
  template&lt;typename T, typename... args&gt;
  struct add&lt;T, args...&gt;
  {
      static constexpr T value = ??//T();//what to write here?
  };
  </code></pre>
  
  <p>Thanks in Advance.</p>