On 2003-12-10T20:19:31-0500, FranklinChen@cmu.edu wrote: > You need a pointer: > > template <class T> > struct super_list > { > T t; > super_list<vector<T> > *children; > }; > > works perfectly well. (Implementation of cool algorithms using > polymorphic recursion left to the reader.) > > Or do you consider this not faithful to your intentions? No, that is perfectly faithful to my intentions, but I can't write an (instantiable) template for << : template <class T> struct super_list { T t; super_list<vector<T> > *children; }; template <class T> ostream & operator<<(ostream &os, super_list<T> const &c) { os << "{"; os << c.t; if (c.children) { os << ","; os << *(c.children); } os << "}"; return os; } Instantiating the function template puts the compiler into a recursion that is depth-bounded only by fiat. So, I'm not sure what cool algorithms using polymorphic recursion can be implemented...? -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig International Human Rights Day * 2003-12-10 * http://www.un.org/rights/ What if All Chemists Went on Strike? (science fiction) http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html
Attachment:
signature.asc
Description: Digital signature