Gennaro said:
There is no reconduction. 14.8.2/2 concerns explicit template
arguments only.
Contrary to what the core issue 488 says, the relevant section is
14.8.2.4.
Did you mean 14.8.2/4?
No, I mean 14.8.2.4 [temp.deduct.type] (the whole section).
Hmm, yes, I think you are right. It's odd that the text of the core
issue gets it wrong, though, even in the proposed resolution from
October 2005!
Thanks for making me notice this.
As I said, Alexandre's reading of the standard seemed pretty correct
to me. So, I wrote to William M. Miller to point out that, apparently,
the text of core issue 488 was referencing the wrong section of the
standard. Here is a summary of the resulting conversation; the text is
slightly edited and reordered to make it (hopefully) clearer in the
context of this thread, and is being forwarded to the newsgroup with
his permission.
WM:
The reference to 14.8.2 in issue 488 is there because the list of
things that cause deduction failures is in 14.8.2 (or, rather, it was;
the version of the Standard incorporating paper N2657 no longer has a
normative list of deduction failures). There was no implication that
14.8.2 was the place that described how template argument deduction
was done for this particular example.
Me:
The problem is, IIUC, that there's no such a thing as "*the* list of
things that cause deduction failures"; but there is "the list of
things that cause deduction failures *when there's an explicit
template argument list*".
WM:
The presentation in 14.8.2 and subsections has always been somewhat
problematic. It's complicated trying to relate all the contexts in
which template argument deduction is done and all the ways a given
template argument value is obtained (explicitly specified, deduced, or
via a default argument), and the fact that the specification evolved,
rather than being written all at once, also contributed to the general
lack of clarity.
However, the intent behind the statement "Type deduction may fail for
the following reasons" was that the following list of bullets applied
regardless of whether the template arguments were deduced, explicitly
specified, or from a default template argument. (That also applies to
the second bullet in that list [not sub-bullet], requiring that a
non-type template argument be convertible to the type of the
corresponding parameter.) The idea was that you first substitute any
explicit template arguments, then attempt to deduce the remaining
arguments as specified in the subsections of 14.8.2, then use default
arguments for any parameters that do not have arguments at that point.
If, after substituting all the arguments for uses of parameters in the
declaration, you end up with a type that is invalid for any of the
reasons in 14.8.2p2, deduction fails for that particular
specialization.
You can see that intention reflected, although imperfectly, in the
wording of 14.8.2p5 (in the current WP; it was similar in the
Standard, but missing the mention of default arguments):
When all template arguments have been deduced or obtained
from default template arguments, all uses of template
parameters in non-deduced contexts are replaced with the
corresponding deduced or default argument values. If the
substitution results in an invalid type, as described above,
type deduction fails.
Note the explicit linking of deduced and default arguments, not just
explicitly-specified arguments, with the reference to p2 ("as
described above").
I think the revision in the current WP makes this clearer, although
I'm sure that further improvement is possible.
Me:
Ah, thanks! [...] I had noticed the wording in 14.8.2p5; in fact
here's what I wrote on c.l.c++.m:
The text of core issue 488, which I linked to in the other
post, already mentions the relevant sections of the standard,
particularly 14.8.2 [temp.deduct] par. 2 [snip...] (In and of
itself that section concerns the case of explicitly specified
template arguments, but then the deduced case is re-conducted
back to the former).
When I say "re-conducted back" I'm thinking exactly of the "as
described above" which you cite. But A. Courpron replied to that with
There is no reconduction. 14.8.2/2 concerns explicit template
arguments only. Contrary to what the core issue 488 says, the
relevant section is 14.8.2.4.
and, upon strict reading, he seemed to be correct.
WM:
I hadn't thought about it from that perspective, but it's easy to see
how one would reach that conclusion from the existing wording. That
does appear to be what it's saying, but that was not the intent.
Hopefully things will be better with the current revision.