[Issue 1528] [tdpl] overloading template and non-template functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 14 15:34:57 PDT 2013


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



--- Comment #27 from timon.gehr at gmx.ch 2013-03-14 15:34:50 PDT ---
(In reply to comment #25)
> I find the C++ rule pretty plausible.
> 
> > In most cases a function template behaves just like a normal function when
> > considering overload resolution. The template argument deduction is
> > applied, if it succeeds, the function is added to the candidates set. Such
> > a function is handled like any other function, except when two viable
> > functions are equally good, the non-template one is selected. In case both
> > are a specialisation of a function template, partial ordering rules are
> > applied. The partial ordering rules are out of the scope of this article.
> 
> http://accu.org/index.php/journals/268#d0e340

C++ does not have template value parameters. The C++ behaviour is approximated
closely when IFTI type parameter deduction is treated as exact match. (There is
no reason to do anything else, a type is required, and a type is given.)

However, it is not too clear that there must be one matching level for the
template and one for the function.

@Kenji, why do you think this is required? Why does one matching level for
everything not suffice?

Eg, I think the following code should not compile and show an ambiguity error.

void foo(double a)(int b){ }
void foo(int a)(double b){ }

void main(){
    foo!1(1);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list