Problem in g++ ?

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

 



Hi all

I have the following piece of code which I believe to be correct, but I get an error from g++.
Same results with 4.8.3 and 4.9.0 (opensuse).
Is this a bug or is there some C++ subtlety which I have missed? If the former, is there a workaround? Otherwise could someone point out how I should fix the code?

Many thanks
Andrew


================================================
template<class A> class X
{
    class GenBase;

public:
    template<class B, class C> class Base;
    template<class B, class C> class Data;
};

// definition of X<A>::GenBase
template<class A0>
class X<A0>::GenBase
{
};

// definition of X<A>::Base<B, C>
template<class A1> template<class B0, class C0>
class X<A1>::Base : public X<A1>::GenBase
{
};

// definition of X<A>::Data<B, C>
template<class A2> template<class B1, class C1>
class X<A2>::Data : public X<A2>::Base<B1, C1>
{
};

// note: error occurs even without the following code
main()
{
    X<int>::Base<short, long>  base;

    X<int>::Data<short, long> stuff;
}

==============================================
g++ output:

test.cpp:24:46: error: ‘typename X<A>::Base’ names ‘template<class A> template<class B, class C> class X<A>::Base’, which is not a type
 class X<A2>::Data : public X<A2>::Base<B1, C1>
                                              ^
test.cpp:24:35: error: ‘typename X<A>::Base’ names ‘template<class A> template<class B, class C> class X<A>::Base’, which is not a type
 class X<A2>::Data : public X<A2>::Base<B1, C1>
                                   ^
test.cpp:25:1: error: expected class-name before ‘{’ token
 {
 ^

===============================================




[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