22std::string
word_wrap(
const std::string& str,
unsigned int wrap) {
24 out.resize(str.size());
26 std::string::size_type i = 0, last_space;
28 while (i < str.size())
30 last_space = std::string::npos;
33 for (std::string::size_type count = 0; count < wrap; ++count)
35 if (i == str.size()) {
52 if (last_space != std::string::npos)
55 out[last_space] =
'\n';
57 if (i == str.size()) {
67 while (i != str.size() && !
is_space(str[i]))
70 if (i == str.size()) {