auto parameter causing template (suggestion for D)

david davidl at
Fri Sep 22 21:04:07 PDT 2006

take a look at this:

import std.stdio;
void myoverload(auto foo)
static if (is ( typeof(foo):int ) )
     { writefln("int");
     static if (is ( typeof(foo):char[] ) )
     { writefln("char[]");
void main()

Though this is a trivial improvement to D language. but I think that  
affect people differently in their mind. People would no longer notice  
they are writing a template for that myoverload
People would see that function as a normal function.
Though that would lost the type information where we can get from void  
myoverload(T)(T t) directly from T, I think typeof(foo) won't bother too  
much! And it's really elegant way to implement in that way.

More information about the Digitalmars-d mailing list