Problem in g++ ?
Andrew
ajc@gmx.net
Thu Apr 30 04:48:00 GMT 2015
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
{
^
===============================================
More information about the Gcc-help
mailing list