Ah, you're right. Whenever I see the square brackets my brain automatically things "we're indexing something". I'll blame that on C. :p
Thanks. Steven Schveighoffer Wrote: > On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic > <andrej.mitrov...@test.com> wrote: > > > I was reading about the various range templates in std.range and I found > > this: > > > > http://www.digitalmars.com/d/2.0/phobos/std_range.html#isInfinite > > > > Seems simple enough. But I dont understand it's implementation, this > > from range.d: > > > > template isInfinite(Range) > > { > > static if (isInputRange!Range && is(char[1 + Range.empty])) > > enum bool isInfinite = !Range.empty; > > else > > enum bool isInfinite = false; > > } > > > > What does char[1 + Range.empty] do? It looks rather cryptic.. > > char[1+Range.empty] is a type. If Range.empty is a compile-time constant, > then this type is valid, otherwise it's not valid (the is expression > results to true if the argument is a valid type). > > If it's valid, then Range.empty never changes. If it never changes and > it's always false, then it's infinite. > > -Steve