OutputRange should be infinite?
Johannes Pfau
nospam at example.com
Sat Oct 6 00:48:48 PDT 2012
Am Fri, 05 Oct 2012 17:15:44 +0200
schrieb "monarch_dodra" <monarchdodra at gmail.com>:
> A good while ago, I ran into some issues regarding output ranges.
> (reference
> http://forum.dlang.org/thread/xyvnifnetythvrhtcexm@forum.dlang.org)
>
> The gist of the problem is that with "put" an OutputRange that
> accepts a T will accept a Range!T, and a Range(Range!T) and a
> Range!(Range(Range!T)) add infinitum.
>
> This all works nice and well, provided the output range does not
> ever become empty => is infinite. However, this is currently not
> the case, and this code will blow in your face:
>
> //--------
> auto a = new int[](1);
> auto b = new int[](2);
> assert(isOutputRange!(typeof(a), typeof(b)));
> if(!a.empty)
> put(a, b); //Nope
> //--------
> auto a = new int[](10);
> auto b = new int[][](3, 5);
> assert(isOutputRange!(typeof(a), typeof(b)));
> if(a.length > b.length)
> put(a, b); //Nope
> //--------
Couldn't we just fix std.range.put to check for an 'empty' property?
More information about the Digitalmars-d
mailing list