Trimming internal whitespace in std::string
I'm looking for an elegant way to transform an std::string from something like:

    std::string text = "   a\t   very  \t   ugly   \t\t\t\t   string       ";

To:

    std::string text = "a very ugly string";

[edit]
Thus, multiple whitespaces, and tabs, are reduced to just one space
[/edit]

Removing the external whitespace is trivial. But is there an elegant way of removing the internal whitespace that doesn't involve manual iteration and comparison of previous and next characters? Perhaps something in <code>boost</code> I have missed?
Trimming internal whitespace in std::string
===

I'm looking for an elegant way to transform an std::string from something like:

    std::string text = "   a\t   very  \t   ugly   \t\t\t\t   string       ";

To:

    std::string text = "a very ugly string";

[edit]
Thus, multiple whitespaces, and tabs, are reduced to just one space
[/edit]

Removing the external whitespace is trivial. But is there an elegant way of removing the internal whitespace that doesn't involve manual iteration and comparison of previous and next characters? Perhaps something in <code>boost</code> I have missed?