Steven T. Hatton wrote:
Quote:
Rather than start a thread I'm gonna segue off this one. _C++ Templates:
The Complete Guide_ provides a list of criteria for determining the
signature of a function or function template. A footnote acknowledges that
their list is distinct from what the Standard provides, but claims it is
functionally equivalent. One criterion the authors of the book list is
return type. I have been given to believe that return type is signally
absent from the criteria determining signature. Am I mistaken?
|
Actually, you'd have been better off starting a distinct thread,
probably: anyone who decides they aren't interested in the original
thread might set their reader to ignore that thread, and thus would
miss out on your new question.
To answer your question: you are correct... _when_ you're not talking
about function templates. From the standard:
13.3#2:
When an overloaded function name is used in a call, which overloaded
function declaration is being referenced is determined by comparing the
types of the arguments at the point of use with the types of the
parameters in the overloaded declarations that are visible at the point
of use.
Note that there is no mention of return types. The section that gives
more details on this mechanism also corroborates this text, as does
13.3.1#2, which specifies that functions differing only in return type
may not be overloaded (and thus, any program which declares such
functions in the same scope is ill-formed).
However:
14.5.5.1#4:
The signature of a function template consists of its function
signature, its return type and its template parameter list.
This does /not/ mean, however, that a compiler can somehow determine
which function template to use when two such templates differ only in
return type. Actually, after staring at the relevant portions of the
Standard for a while, I'm not /entirely/ sure what it /does/ mean;
it'll take some more poring over (or a more knowledgable poster) to
clear that up for me. After all, the definition of a signature is "the
information about a function that participates in overload resolution";
but what role it plays in resolving overloads is not yet clear to me.