'typeof' not printing template arguments.

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


On Wednesday, 12 July 2017 at 00:44:38 UTC, Deech wrote:
> 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

nm, dumb mistake on my part. I had a `calculate` at the top of 
the file and missed it. Sorry.


More information about the Digitalmars-d-learn mailing list