public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* problem with a structure nested within a template
@ 2006-11-21 18:05 Paul Ianna
  2006-11-21 18:28 ` Young, Michael
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Ianna @ 2006-11-21 18:05 UTC (permalink / raw)
  To: gcc-help

Hi All,

I'm perplexed and hoping to obtain some guru insight from the community.

The code below is a snippet from some existing code that compiles with
many other compilers, but not gcc (I tried both 3.4.4 and 4.1.1
versions).

The problem line is:  C1<U>::Node*    pNode;

and the error is:  error: expected `;' before '*' token

If I use a concrete type (e.g., C1<int>), all is well.

Thanks in advance,
Paul


///////////////////////////////////////
template<typename T>
class C1
{
public:

   struct Node
   {
      T*     prev;
      T*     next;
   };

   Node   myNode;
};



///////////////////////////////////////
template<typename U>
class C2
{
public:

   U                       someObj;
   C1<U>::Node*    pNode;
};


///////////////////////////////////////
int main()
{
   C1<int> c1;

   C2<int> c2;

   return 0;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: problem with a structure nested within a template
  2006-11-21 18:05 problem with a structure nested within a template Paul Ianna
@ 2006-11-21 18:28 ` Young, Michael
  2006-11-21 18:40   ` Young, Michael
  0 siblings, 1 reply; 3+ messages in thread
From: Young, Michael @ 2006-11-21 18:28 UTC (permalink / raw)
  To: Paul Ianna, gcc-help

> The problem line is:  C1<U>::Node*    pNode;

I *think* this is a "type-dependent id expression" (in std lingo), because "U" is a template parameter type.
You should be able to write the following and get rid of this problem...

typename C1<U>::Node*  pNode;

HTH,
  Michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: problem with a structure nested within a template
  2006-11-21 18:28 ` Young, Michael
@ 2006-11-21 18:40   ` Young, Michael
  0 siblings, 0 replies; 3+ messages in thread
From: Young, Michael @ 2006-11-21 18:40 UTC (permalink / raw)
  To: Paul Ianna, gcc-help

I may have been wrong in the nomenclature - it may be a "qualified-name" (14.6 p3).  Either way, the proposed solution should work.
  - Michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-21 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-21 18:05 problem with a structure nested within a template Paul Ianna
2006-11-21 18:28 ` Young, Michael
2006-11-21 18:40   ` Young, Michael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).