Overloading function with a generic function fails
Abid H. Mujtaba
abid.naqvi83 at gmail.com
Thu May 12 10:01:05 PDT 2011
This is another example from "The D Programming Language" by Andrei Alexandrescu. Compiling the following:
// Code in test.d:
void transmogrify( uint x ) {}
void transmogrify( long x ) {}
void transmogirfy(T)( T x ) {}
unittest {
transmogrify( 42 ) ;
}
fails with the following error (when compiled with 'rdmd --main -unittest test.d' :
test.d(3): Error: template test.transmogrify(T) conflicts with function test.transmogrify at test.d(1)
As I understood it the D compiler is capable of setting up a partial ordering of functions and choosing one of the three overloaded functions based upon how it was called.
Note: The example above works if I remove the generic function that is overloading works for explicit types but not for generic types.
More information about the Digitalmars-d
mailing list