This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug or my mistake?
- From: Gareth McCaughan <gmccaughan at synaptics-uk dot com>
- To: Lally Singh <death_to_nt at mac dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 24 Nov 2003 12:07:57 +0000
- Subject: Re: Bug or my mistake?
Lally Singh wrote:
> template<class T>
> struct foo {
> enum { foo_value = 1 };
>
> struct bar {
> enum { bar_value = 1 };
> };
>
>
> template<class U>
> struct baz {
> enum { baz_value = 1 };
> };
> };
...
> return foo<T>::baz<U>::baz_value; // Line (3)
You need to qualify "baz" there with the "template"
keyword:
return foo<T>::template baz<U>::baz_value;
because the compiler can't rely on "baz" naming a template:
an explicit specialization of "foo" might make it be something
else. The standard says that in such potentially-ambiguous
cases, a non-template is assumed unless you use the "template"
keyword.
Just to clarify, here's the sort of nastiness I mean.
template<>
struct foo<int> {
int baz;
};
--
Gareth McCaughan