Overloading and templates

Stewart Gordon smjg_1998 at yahoo.com
Wed Mar 28 07:08:14 PDT 2007


"Falk-Florian Henrich" <schreibmalwieder at hammerfort.de> wrote in message 
news:pan.2007.03.27.18.42.25 at hammerfort.de...
> 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.
<snip>

This is just one case of something that's been brought up quite a few times:

http://d.puremagic.com/issues/show_bug.cgi?id=52

Stewart. 




More information about the Digitalmars-d mailing list