is(this == bug) ???

dsimcha dsimcha at yahoo.com
Wed Apr 1 16:53:20 PDT 2009


== Quote from dsimcha (dsimcha at yahoo.com)'s article
> void doStuff(T)(T arg)
> if(is(typeof(arg))) {
> }
> void main() {
>     doStuff(1);
> }
> Results:
> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) does not match any
> function template declaration|
> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) cannot deduce
> template function from argument types !()(int)|
> This code does not compile with 2.027, 2.026, or 2.016 (the first version that
> had constraints).  If it is, in fact, a bug, I find it amazing that it's
> apparently taken over half a year for anyone to notice.  (Searching bugzilla
> for "constraints" yields nothing.)  If it's not a bug, then I can't for the
> life of me figure out why it won't compile.

(Slapping forehead)

Never mind.  After struggling with this for an hour, I realized that arg is not in
scope when the constraint is evaluated.



More information about the Digitalmars-d mailing list