https://issues.dlang.org/show_bug.cgi?id=15285
--- Comment #5 from Jonathan M Davis <[email protected]> --- > So you mean we could add to isSomeString a RangeString? I mean something like if(isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { } which is what some of the functions in std.string already have. In some cases, a bidirectional or random-acesss range might be required, but it's a range of char, wchar, or dchar that isn't an array. > 1) can we replace for --> foreach or do we have to use `static if`? That would depend entirely on the function. In many cases, you'd probably end up with a different overload. For instance, that's what indexOf did. Some of its overloads operate on strings, whereas others operate on aribtrary ranges of characters. > 2) we still will return a newly allocated immutable string. Should we return > something different for ranges? That would depend on the function. If the function is supposed to return a newly allocated string, then that's probably what it's going to need to do, but in some cases, it may be able to return the original range (or a slice of it), and most functions that return a newly allocated array should eventually have a counterpart that returns another range type so that it can avoid allocations. But essentially, what we want is for the functions in std.string to operate on arbitrary ranges of characters in a way that's compatible with the current API. Generic code will need to work the same way with these functions whether they're taking strings or ranges. But exactly what needs to happen is going to depend on the function in question, and we'll have to look at that on a case by case basis. --
