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.

Required fields*

3
  • Just a note, I've not really used boost::split and boost::join, but the obvious way to write this in Python is ' '.join(text.split()), and something similar should be possible. It's not necessarily as efficient as something that copies the bytes straight to their final location, but it's concise and clear. Commented Feb 19, 2012 at 19:01
  • Yeah; split and join work great if you don't mind copying; if you are worried about efficiency (in this case), writing your own loop is probably best. Commented Feb 19, 2012 at 19:29
  • @Marshall: I'm working on the basis that the question says, "elegant", not "fast but ugly" ;-) Commented Feb 20, 2012 at 9:50