A problem with templates and static array initializers...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux