D-Programming-Language/phobos — pull request #2203 by monarchdodra (2014-05-25 15:12:54+00:00)
Title: Constrain isSomeString

This pull adds a restriction to `isSomeString!S` to be an actual dynamic arrays you can iterate on, pop and save. A range in general:
```D
char[], const(wchar)[], dstring; //YES
```
But not static arrays, which are more like static arrays, and can't be popped.
```D
char[80] buf; //NO
```

The rationale for this is that as currently implemented, it `isSomeString` is virtually *useless* in template constraint. For example:
```D
if (isRandomAccessRange!R || isSomeString!R)
```
The problem here is that it makes `char[80]` an acceptable parameter, when it isn't an actual range. I don't think it is acceptable to burden template constraint to check that a string is also a range. Testing for a string should simply certify that the string is of the dynamic flavor that's actually expected...

After reviewing the restraint in `std.algorithm` or `std.range`, I can say that currently, a *lot* of our constraint are wrong, and need fixing.

--------

In case some code *REALLY* want to accept a static array as a "string-like" input, I also changed `StringTypeOf` to always return the dynamic array of what you passed in. As such:
```D
StringTypeOf!(char[80]) => char[];
```

This actually turned out useful, and there are a few places where it even solved a compile error.

--------

Overall, this is breaking change. But it breaks relatively little code, and I think necessary to be able to work with generic objects while keeping your sanity...

Also fixes https://issues.dlang.org/show_bug.cgi?id=12796