Re: Rationale for 14.3.2/5 [temp.arg.nontype], pointer to object
non-type template-parameters
Daniel Kr=FCgler ha scritto:
So, if VS2005 compiles this successfully (modulo function definition),
it behaves non-conforming in this regard (Even VS2005-SP1
does accept this program).
Interesting. How does VS2005 compile this, then?
struct base{};
struct derived:base{};
template<base*> void foo() {}
template<derived*> void foo() {} // overload!
derived d;
int main()
{
foo<&d>(); // should unambigously select foo<derived*>
}
For the OP: this example might show the rationale that you were asking.
If you allow derived-to-base conversion, foo<derived*> can never be
called, unless complex "best-match" rules are further introduced to
disambiguate this scenario. I've never seen this case used in practice,
so I guess the committee decided that writing down those rules just
wasn't worth the effort.
However, the question remains for class templates, because in that case
you can't overload the template and the shown ambiguity never arises.
Just my 2 eurocents,
Ganesh
---
[ 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://www.comeaucomputing.com/csc/faq.html ]