title: Variadic template function to create string
body: <p>I'm new to variadic template functions. I have written a simple class, <code>StringStream</code>, that has a variadic template function that creates a <code>std::string</code> from variable template arguments - strings, ints, etc.</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;sstream&gt;
  
  class StringStream
  {
  public:
      StringStream() = default;
      ~StringStream() = default;
  
      template&lt;typename T&gt;
      std::string Stringify(const T &amp;value)
      {
          mStream &lt;&lt; value;
          return mStream.str();
      }
  
      template&lt;typename T, typename... Ts&gt;
      std::string Stringify(const T&amp; value, Ts... values)
      {
          mStream &lt;&lt; value;
          return Stringify(values...);
      }
  
  private:
      std::stringstream mStream;
  };
  </code></pre>
  
  <p>What I want to do now is use a <code>std::string</code> member in <code>StringStream</code> instead of <code>std::stringstream</code> and build the string from the arguments of <code>Stringify()</code>. For arguments that are not <code>std::string</code> I want to convert to strings with <code>std::to_string()</code>, otherwise I just concatenate the argument. I am running into a compiler error. Here's my modified class:</p>
  
  <pre><code>class StringStream
  {
  public:
      StringStream() = default;
      ~StringStream() = default;
  
      template&lt;typename T&gt;
      std::string Stringify(const T &amp;value)
      {
          mString += std::to_string(value);
          return mString;
      }
  
      template&lt;&gt;
      std::string Stringify&lt;std::string&gt;(const std::string&amp; value)
      {
          mString += value;
      }
  
      template&lt;typename... Ts&gt;
      std::string Stringify(const std::string&amp; value, Ts... values)
      {
          mString += value;
          return Stringify(values...);
      }
  
      template&lt;typename T, typename... Ts&gt;
      std::string Stringify(const T&amp; value, Ts... values)
      {
          mString += std::to_string(value);
          return Stringify(values...);
      }
  
  private:
      std::string mString;
  };
  </code></pre>
  
  <p>My compiler error says:</p>
  
  <p>error C2665:  'std::to_string': none of the 9 overloads could convert all the argument types</p>
  
  <p>I am calling the function like this:</p>
  
  <pre><code>int main()
  {
      int age;
      std::cin &gt;&gt; age;
      StringStream ss;
      std::cout &lt;&lt; ss.Stringify("I", " am ", age, " years ", "old") &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Is there any way to resolve this?</p>