This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]