On 14 Apr., 18:35, Gerhard Menzl <clcppm-pos...@[EMAIL PROTECTED]
>
wrote:
> Daniel Krügler wrote:
> > The standard clearly says that a function must exist in this case.
> > This can be deduced by the combination of [basic.def.odr]/2:
>
> > "An overloaded function is used if it is selected by overload
> > resolution when referred to from a potentially-evaluated expression."
>
> > with [over.over]/1:
>
> > "A use of an overloaded function name without arguments is resolved in
> > certain contexts to a function, a pointer to function or a pointer to
> > member function for a specific function from the overload set. A
function
> > template name is considered to name a set of overloaded functions in
such
> > contexts.[..]"
>
> Thanks for pointing me to these passages, but I find them anything but
> clear. Does this really apply to taking the address of the function
> template specialization?
Let's unroll it from end to begin: [over.over] provides the rules
about "Address of overloaded function" and p.1 (quoted above)
just describes the syntactic manifold of taking the pointer to
a (free or static member) function, pointer to member function, etc.
It clarifies in this context that any function template used
like this follows the same rules as a "set of overloaded" functions.
The last point is im****tant, because it gives us the correct
link to what entity we have to refer for.
I assume that you hesitation is based on the fact that [over.over]
speaks of a "template name" and not of a "template id". If so, your
hesitation is primarily profound, because this paragraph does not
*clearly* say whether it wants to include the case of a template with
explicitly specified template arguments. But at this point this
case is not explicitly excluded. To be sure we have to read a
bit further (and I apologize for not providing this information in
the first place) in p.2:
"If the name is a function template, template argument deduction is
done (14.8.2.2), and if the argument deduction succeeds, the
resulting
template argument list is used to generate a single function template
specialization, which is added to the set of overloaded functions
considered."
Note that this paragraph speaks of "resulting template argument list"
which includes the case of explicitly provided arguments. This
wording was chosen as part of
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#250
to express exactly this intend.
The quote of [basic.def.odr] is relevant, because if defines the
term of "usage" and thus implies the existence of the definition
of the offending function.
Even though you will find a lot of issues regarding [over.over],
these are actually all issues which clarify situations that could
be interpreted to lead to ambiguities or ill-formed code (E.g.
#250 belongs to this category). Obviously the VC6 compiler does
not cause this kind of problems here, because according to your
description the code *compiles* and is well-formed. There is no
doubt, that the expression
std::sort(vc.begin(),
vc.end(),
lessMember<C, long, &C::GetLong>);
is "potentially evaluated" and that a given specialization of
lessMember *is used*, otherwise this code would not make much
sense. Taking all this together I would say that this is a clear
compiler or linker error.
I hope this explanation was a bit clearer than the first.
Greetings from Bremen,
Daniel Krügler
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|