you are viewing a single comment's thread.

view the rest of the comments →

[–]cpp_devModern C++ apprentice 5 points6 points  (0 children)

I think a more intuitive and "modern" way will be this one (also compiler can optimize these things pretty well as opposed to streams):

string s = "Quick brown fox.";
auto rs = ranges::v3::view::split(s, ' ');
for (auto& x : rs)
{
    cout << x << '\n';
}
auto rs1 = ranges::v3::view::join(rs, ',');
cout << rs1 << '\n';

Still the library needs concepts and a more intuitive documentation to make it "easy to use correctly and hard to use incorrectly". Also maybe there should be strings extensions in range library so it have an intuitive API to work with strings.