This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why is this still not allowed by gcc while MSVC does(const template argument)
- From: Ian Lance Taylor <iant at google dot com>
- To: "Jun Chen" <chjfth at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 05 Nov 2007 07:49:11 -0800
- Subject: Re: Why is this still not allowed by gcc while MSVC does(const template argument)
- References: <fd3446460711040400w61f115f6u307964cd44d976aa@mail.gmail.com>
"Jun Chen" <chjfth@gmail.com> writes:
> Please check the following small program:
This is the wrong mailing list. Please use gcc-help@gcc.gnu.org for
questions about using gcc. The mailing list gcc@gcc.gnu.org is for
developers of gcc itself. Please take any followups to
gcc-help@gcc.gnu.org. Thanks.
> {code}
> t1.cpp:56: error: could not convert template argument '0' to 'MyClass*'
> t1.cpp:56: error: invalid type in declaration before ';' token
> t1.cpp: In function 'int main()':
> t1.cpp:63: error: invalid types 'CecMyClass[int]' for array subscript
> t1.cpp:64: error: invalid types 'CecMyClass[int]' for array subscript
> {code}
>
> I'm really baffled! Since 0 can be assigned to any pointer variable,
> then why "0 could not be converted to MyClass* "?
The C++ standard is clear: "Although 0 is a valid template-argument
for a non-type template-parameter of integral type, it is not a valid
template-argument for a non-type template-parameter of pointer type."
(14.3.2 Template non-type arguments [temp.arg.nontype]).
Ian