
Germán Diago wrote:
I wouldn't find it ok for split to return a vector<string> since I like to be kept in control of how I store my elements, and there is no control without taking the container as an argument or using the method I just mentioned.
I would like to be able to use it like this:
split(str, predseparators);
Which returns a range. I think this is possible. You always return a range, and if you want to store it, you can copy the returned range to a vector<string>, for example. So it would be quite realistic (I think) to adapt split so that returns always ranges and if you want a copy, make a explicit copy in the code:
auto r = split(str, predseparators);
vector<string> vec(r.begin(), r.end());
Which is the mechanism I offered, i.e. lazy evaluation with range adapters.