title: Format number with commas in C++
body: <p>I want to write a method that will take an integer and return a <code>std::string</code> of that integer formatted with commas.</p>
  <p>Example declaration:</p>
  <pre><code>std::string FormatWithCommas(long value);
  </code></pre>
  <p>Example usage:</p>
  <pre><code>std::string result1 = FormatWithCommas(7800);
  std::string result2 = FormatWithCommas(5100100);
  std::string result3 = FormatWithCommas(201234567890);
  // result1 = &quot;7,800&quot;
  // result2 = &quot;5,100,100&quot;
  // result3 = &quot;201,234,567,890&quot;
  </code></pre>
  <p>What is the C++ way of formatting a number as a <code>string</code> with commas?</p>
  <p>(Bonus would be to handle <code>double</code>s as well.)</p>