Topic: Partial ordering of function templates: 14.5.5.2
Author: "Sanjay Pujare" <sanjayp@ddi.com>
Date: 1999/07/02 Raw View
I have a question about an example given in the standard (14.5.5.2):
template<class T> void g(T);
template<class T> void g(T&);
void m() {
float x;
g(x); // Ambiguous: g(T) or g(T&)
}
How can they say this is ambiguous? Isn't the second function template
more specialized than the first one? The second function template can
be used only when function argument is an lvalue (i.e. can be
a (T &) - reference to any type T). Whereas the first one can be used
for any type T. So for example, given the call
g(3.0);
only the first template can be instantiated, but not the second one. Or am
I missing something?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]