Understanding isInfinite(Range)

Peter Alexander peter.alexander.au at gmail.com
Sat Sep 4 04:08:28 PDT 2010


== Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> On Fri, 03 Sep 2010 11:12:29 -0400, Andrej Mitrovic
> <andrej.mitrovich at test.com> wrote:
> > 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

That's really ugly code :-(

Is there a way you could write an isStatic(expr) template? Using something like that would make the
code a hell of a lot more readable. At the moment, the code itself does a very poor job of conveying
what it's trying to accomplish.

These SFINAE-like tricks should be black-boxed as much as possible, or (at the very least)
commented so that people know what's going on.


More information about the Digitalmars-d-learn mailing list