Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Thanks, that seems to be working. How do I get back from an std::ostream to std::string though? Shifting it into std::cout doesn't seem to work for example. Commented Jun 19, 2014 at 20:22
  • 2
    @CyDek If foo really needs an ostringstream you should use your working method instead of modifying the function to take an ostream. If you really want to follow your other method, then you could cast the ostream back to ostringstream (static_cast<std::ostringstream&>(in).str()) but then it'd be undefined behavior if someone calls foo with some other kind of ostream Commented Jun 19, 2014 at 20:30
  • @Praetorian Thanks, works like a charm. Since I'm really just experimenting for learning purposes I am actually quite fine with that :) Commented Jun 19, 2014 at 20:35