Problem in g++ ?
Roger Ferrer Ibáñez
rofirrim@gmail.com
Thu Apr 30 05:46:00 GMT 2015
Hi,
I do not know whether this is a bug in g++.
As a workaround changing this
class X<A2>::Data : public X<A2>::Base<B1, C1>
into this
class X<A2>::Data : public X<A2>::template Base<B1, C1>
works for me.
Kind regards,
2015-04-30 6:47 GMT+02:00 Andrew <ajc@gmx.net>:
> 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
> {
> ^
>
> ===============================================
--
Roger Ferrer Ibáñez
More information about the Gcc-help
mailing list