Overloading and templates
Falk-Florian Henrich
schreibmalwieder at hammerfort.de
Tue Mar 27 11:41:53 PDT 2007
Hi,
the following question concerns future plans regarding overloading rules
and templates. Currently, there exists the following problem: Suppose I
have a templated function
Y[] map(X,Y)(Y function(X[]) f, X[] x);
Now, if I have a couple of overloaded print functions
char[] toString(int);
char[] toString(double);
and do
map(&toString, x);
where x is some double[], the compiler will grab toString(int) instead of
its double version. Actually, the compiler grabs just *the first function
it finds* in the source file - although it does know that the types won't
match.
1. Why does the compiler only compare the function's name with the given
candidates, and not the types?
2. Are there any plans to overcome this limitation?
Best regards
Falk
P.S.: I tried several template constructions to find a workaround but
didn't succeed so far.
More information about the Digitalmars-d
mailing list