This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
A problem with templates and static array initializers...
- From: Joseph Galbraith <galb at vandyke dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 26 Jan 2005 14:19:14 -0700
- Subject: A problem with templates and static array initializers...
I have this code (below) which compiles with
older versions of g++, Visual C++ and xlC,
and looks correct to me.
But, 3.4.2 is rejecting it.
Now I know all those compilers (and me too)
could (probably) be wrong and the code is
wrong...
So the question is, is the following code
incorrect, and if so, how do I fix it.
template<class T>
class Base
{
public:
struct _BaseStruct
{
int x;
int y;
};
private:
static const _BaseStruct _table[];
};
class Derived : public Base<Derived>
{
};
const Base<Derived>::_BaseStruct Base<Derived>::_table[] =
{
{ 1, 2 },
{ 4, 5 },
};
It fails to compile with this error:
x3.cpp:19: error: too few template-parameter-lists
x3.cpp:19: error: expected `,' or `;' before '=' token
[galb@random temp]$ gcc --version
gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)1
Thanks,
Joseph