Re: Rationale for 14.3.2/5 [temp.arg.nontype], pointer to object non-type template-parameters
On Mar 6, 8:35 am, "h.yuz...@gmail.com" <h.yuz...@gmail.com> wrote:
Did you forgot to define the function body of the foo()? If so, you
will get a linking error, not compilation error. I tested your code in
VS2005 and got the linking error. After defining the foo(), every
thing gone well.
Strictly speaking you are right. As I learned recently, using an
undefined
entity belongs to the UB realm.
But even if he would fix this issue by simply providing a proper
definition,
e.g.
template<base*> void foo() {}
this program should not compile (as Joaqu?n correctly pointed out),
because of what 14.3.2/5 demands:
"for a non-type template-parameter of type pointer to object,
qualification
conversions (4.4) and the array-to-pointer conversion (4.2) are
applied.
[ Note: In particular, neither the null pointer conversion (4.10) nor
the
derived-to-base conversion (4.10) are applied.[..]"
So, if VS2005 compiles this successfully (modulo function definition),
it behaves non-conforming in this regard (Even VS2005-SP1
does accept this program).
Greetings from Bremen,
Daniel Kr?gler
---
[ 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 ]