title: How can I convert a list of integer into comma separated string?
body: <p>I am currently implementing an new software. While parsing a file, I collect a list of line numbers which were skipped. After parsing I would like to output all line numbers as comma separated string.</p>
  
  <p><strong>How can I convert a <code>std::list&lt;int&gt;</code> into a <code>std::string</code> as comma separated list?</strong></p>
  
  <p>Assume this code segment as framework:</p>
  
  <pre><code>#include &lt;list&gt;
  #include &lt;string&gt;
  
  void parseFile()
  {
      std::list&lt;int&gt; skippedLines;
      // ...parse file...
      if (!skippedLines.empty()) {
          const std::string skippedLinesAsString = ???
          log &lt;&lt; "Skipped lines: " &lt;&lt; skippedLinesAsString;
      }
  }
  </code></pre>
  
  <p><em>Please note, I need a <code>std::string</code> as result. The shown stream is just for illustration purposes and can not be used for output.</em></p>
  
  <p>I implemented it in a traditional way using a loop. But I am sure there is a simple algorithmic solution using a back-inserter or similar.</p>