On 12 Pro, 19:42, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
Victor Bazarov wrote:
highegg wrote:
given the declarations
class A {};
template <class X, class T> void method (double u, T v);
template <class X> void method (double u, long v);
...
double u; long v;
Is the following call unambigous (w.r.t. C++ standard)?
method<A> (u, v);
[..]
Yes.
I meant to say it was ambiguous. If you know what part of the Draft
says the second is a better match, could you point to it, please?
From what I figure, the first template could be more specialised than
the second because it has two types defined, not just one. However, all
the examples given in the Standard have to do with A<T*> vs A<T> (which
makes the former more specialised) and not A<T,U> vs A<T>. My
understanding of what makes templates "more specialised" can be
incorrect, so I'd appreciated somebody's explanation.
Hi Victor,
after reading the relevant sections thoroughly, I think it is the
partial template ordering rules in 14.5.5.2 that account for the
unambigous resolution. See the paragraphs 2-5.
Simply said, the reasoning is that the second template's prototype can
be matched by the first, but not vice versa (note the wording in
paragraph 3 saying that a *unique* type is synthesized for each type
template parameter, i.e. for T in this case).
Therefore, the second template is more specialized and will be
preferred.
If anyone thinks I'm wrong with this reasoning, please clarify.
Anyway, thanks to everyone who replied, especially Joe pointing me to
Comeau C++.
Jaroslav Hajek
Thanks, Jaroslav. I take it you meant 14.5.6.2 (not .5.2). I can't
the [temp.func.order] section). Can you please lay your deductions down
the paragraph 3's first sentence I get lost. How does that sentence