Tag: stringstream

  • Some neat examples of C++ String Formatting

    Some neat string formatting

    A pretty neat snippet found on stackoverflow some time ago (kudos David Rodriguez), that is worth repeating. Some time ago, a ‘moderator’ at StackOverflow removed this thread “for reasons of moderation”. Fair enough, but the result is that code that many would find pretty darn useful is no longer searchable on that site. How very constructive. Here is a snapshot of that particular StackOverflow page as preserved by the WayBack Machine:

    http://web.archive.org/web/20090420233428/http://stackoverflow.com/questions/469696/what-is-your-most-useful-c-c-snippet/470999

    I’m gonna start using this. Essentially it is a bit of in-house stream formatting. This class make_string produces an instance of an object derived from ostream, which has an implicit conversion to a std::string: (more…)