Topic: How to do this? CAN it be done???


Author: mat@mole-end.matawan.nj.us
Date: Wed, 2 Dec 1992 18:41:48 GMT
Raw View
I have a template  Stack_HT<> , whose parameters are

 class T --the type to be stacked
 class T_init --a type s.t. there is a  T::T( const T_init& )

I want to create a class  Store  s.t.

 class Store_init;  // Forward declaration

 class Store
 {
   public:
  Store( Store_init& );
  .. .. ..
 };

 typedef Stack_HT< Store, Store_init > Store_init; // Forward declaration
       //   fulfilled.

That is, a  Store 's one parameter is the stack to which it will later
be assigned.  (It could just as well be a FIFO, or whatever).

cfront 3.01 disallows the fulfillment of the forward declaration by
the typedef on the template instantiation.  Note that if I don't
have the forward declaration, then no matter how I order things,
I end up with infinite regress in the template, since the template
instance type is a parameter to the template.

Should this be legal? (For the record,  Stack_HT<>  is a template
class.)  If this is _NOT_ legal, then there is no way to create
mutually referent templates.  I can't create a template for an X
and for a Stack_on_X that have pointers or references to each other.

--
 (This man's opinions are his own.)
 From mole-end    Mark Terribile

 mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ