Topic: Is this address of an overloaded function ambiguous or resolvable?
Author: Faisal Vali <faisalv@gmail.com>
Date: Thu, 30 Sep 2010 01:54:14 CST Raw View
Consider the following example:
template<class T> void f(T); // 1
template<class T> void f(T*); // 2
void (*p)(int*) = &f; // ok, resolves to 2
void (*p2)(int*) = &f<int>; // ok, resolves to 2
but what happens here:
bool b = &f<int>; // is this ambiguous, or is the intent of the
standard to resolve this to 2?
For Schaub's thoughts on the uncertainty regarding its interpretation,
pls refer to: http://llvm.org/bugs/show_bug.cgi?id=7505.
The relevant section in the standard is: [over.over], Section 13.4.
Some excerpts to get you started:
[ Note: As described in 14.8.1,
if deduction fails and the function template name is followed by an
explicit template argument list, the
template-id is then examined to see whether it identifies a single
function template specialization. If it does,
the template-id is considered to be an lvalue for that function
template specialization. The target type is
not used in that determination. end note ]
...
If more than one function is selected, any function template
specializations in the set are eliminated if the
set also contains a non-template function, and any given function
template specialization F1 is eliminated if
the set contains a second function template specialization whose
function template is more specialized than
the function template of F1 according to the partial ordering rules of
14.5.6.2. After such eliminations, if
any, there shall remain exactly one selected function.
Any help will be appreciated - so thanks in advance!
Faisal Vali
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]