Idiomatic way to process const/immutable arrays as ranges

Jonathan M Davis jmdavisProg at gmx.com
Mon Feb 11 12:09:01 PST 2013


On Monday, February 11, 2013 14:56:29 Steven Schveighoffer wrote:
> On Mon, 11 Feb 2013 14:52:51 -0500, Steven Schveighoffer
> 
> <schveiguy at yahoo.com> wrote:
> > With that change, then you can compile my original suggestion, or my
> > later suggestion.
> 
> Actually, it seems that even args.join(" ") works, without changing to the
> tail-const type...
> 
> That is technically correct, but I'm not sure why. I would have expected
> isInputRange!(const string[]) to be false.

It _is_ false.

--------
import std.range;

void main()
{
 assert(!isInputRange!(const string[]));
}
--------

But remember that templated functions which are given array always instantiate 
with the tail-const type of an array (assuming that you use IFTI rather than 
explicit instantiaton), so that may be where the confusion is coming from.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list