'typeof' not printing template arguments.

Deech via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 11 17:44:38 PDT 2017


Hi all,
I've been learning D for a few weeks by reading through 
Programming In D [1] and had a question about Eponymous Template 
section [2]. Here's the example:

```
template LargerOf(A, B) {
   static if (A.sizeof < B.sizeof) {
     alias LargerOf = B;

   } else {
     alias LargerOf = A;
   }
}

LargerOf!(A, B) calculate(A, B)(A a, B b) {
   LargerOf!(A, B) result;
   return result;
}

pragma(msg, typeof(calculate));
```

At build time instead of printing:
```
LargerOf!(A, B)(A, B)(A a, B b)
```

it prints:
```
double(double lhs, double rhs)
```

Is there some reason it specializes to `double`?

-deech
[1] http://ddili.org/ders/d.en/index.html
[2] http://ddili.org/ders/d.en/templates_more.html


More information about the Digitalmars-d-learn mailing list