Article View: gnu.gcc.help
Article #41413TEMPLATE WOES/ strange g++ behavior
From: Mark Mestern
Date: Wed, 27 Mar 1996 00:00
Date: Wed, 27 Mar 1996 00:00
61 lines
1714 bytes
1714 bytes
I've run into a problem with g++ 2.7.2 under Solaris 2.4.
I've got two seemingly equivalent pieces of code one of which produces
a parse error and the other compiles fine. The porblem only occurs
when trying to nest templates without using pointers.
A simple example follows.
---------------------------------------------------------------------------
template <class T> class a
{
T data;
};
template <class T> class d
{
T data4;
};
template class d<a<int>>;
main()
{
}
---------------------------------------------------------------------------
This will give a "parse error before `>'" message on the template line..
However trying the following will get the compiler to accept it
although the structure is the same.
---------------------------------------------------------------------------
template <class T> class a
{
T data;
};
template <class T> class d
{
T data4;
};
typedef a<int> foolthecompiler;
template class d<foolthecompiler>;
main()
{
}
---------------------------------------------------------------------------
Your verdict? Bug (or feature), or something about templates I have still
to learn?
I really hope you can shed light on this - I've spent 8 hours trying
to solve the problem before the typedef solution was suggested to me.
Mark
Technical Details
Message-ID:
<4jbjf5$qsh@groa.uct.ac.za>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,3796bd64e6233993,start X-Google-Attributes: gid11318c,public From: mmestern@cs.uct.ac.za (Mark Mestern) Subject: TEMPLATE WOES/ strange g++ behavior Date: 1996/03/27 Message-ID: <4jbjf5$qsh@groa.uct.ac.za> X-Deja-AN: 144457297 organization: University of Cape Town newsgroups: gnu.gcc.help