Deprecate InputRange source for OutputRanges
An output range for E won't be automatically an output range for [E] anymore. The same, an output range for [E] won't be automatically an output range for E. Automatic E <-> [E] conversion seems to be a nice feature at first glance, but it causes much ambiguity. 1) If I want that my output range accepts only UTF-8 strings but not single characters (because it could be only part of a code point and look like broken UTF-8 without the remaining code units), I can't do it because an OutputRange(R, E) can't distinguish between char and string. 2) Here is an example from 2013: import std.range; import std.stdio; Appender!(const(char)[][]) app; put(app, "aasdf"); put(app, 'b'); writeln(app.data); This outputs: ["aasdf", "\0"]. Whether it is a common case or not, such code just shouldn't compile.
This commit is contained in:
@ -309,7 +309,7 @@ void swap(T)(ref T a, ref T b) @trusted
|
||||
* $(D_PARAM source) elements.
|
||||
*/
|
||||
Target copy(Source, Target)(Source source, Target target)
|
||||
if (isInputRange!Source && isOutputRange!(Target, Source))
|
||||
if (isInputRange!Source && isOutputRange!(Target, ElementType!Source))
|
||||
in
|
||||
{
|
||||
static if (hasLength!Source && hasLength!Target)
|
||||
|
Reference in New Issue
Block a user