Template type deduction and specialization

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 20 02:51:53 PDT 2015


On Wednesday, 20 May 2015 at 09:35:48 UTC, Jonathan M Davis wrote:
>
> Well, if
>
> printVal!(int*)(px);
>
> prints 100, then that's a bug. It should print the address. In 
> fact, it
> should be _impossible_ for the second overload of printVal to 
> ever be
> instantiated

IMHO thats not true, it should print 100. This is what spec say.

void printVal(T : T*)(T* t) {
     writeln(*t);
}

T is deduce to be int so we have

void printVal(int* t) {
     writeln(*t);
}

which will print value not address


More information about the Digitalmars-d-learn mailing list