home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13211 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.7 KB  |  49 lines

  1. Path: sparky!uunet!gumby!wupost!cs.utexas.edu!ut-emx!jamshid
  2. From: jamshid@ut-emx.uucp (Jamshid Afshar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: BC++ templates broken
  5. Summary: a workaround
  6. Message-ID: <78940@ut-emx.uucp>
  7. Date: 2 Sep 92 17:01:17 GMT
  8. References: <1992Aug29.212548.8071@fcom.cc.utah.edu> <1992Aug31.155313.5879@fcom.cc.utah.edu>
  9. Reply-To: jamshid@emx.utexas.edu
  10. Organization: The University of Texas at Austin; Austin, Texas
  11. Lines: 36
  12.  
  13. In article <1992Aug31.155313.5879@fcom.cc.utah.edu> swillden@news.ccutah.edu (Shawn Willden) writes:
  14. >[BC++ and gcc-2.2.2 barf on code like:]
  15.  
  16.      template<class T> class A1;
  17.      template<class T> class A2;
  18.      
  19.     template<class T> class A { A1<T>* a; A2<T>* b;};
  20.     //here
  21.  
  22.      template<class T> class A1 : public A<T> {};
  23.      template<class T> class A2 : public A<T> {};
  24.  
  25.      main() {A1<int> myA1;}
  26.  
  27. >Am I asking something too difficult?
  28.  
  29. I hope not.  ANSI C++ will require that cases such as this are handled
  30. properly, right?  Does cfront 3.0 handle it?  I reported this bug a
  31. couple of weeks ago to bugs@borland.com (not for tech. support) and
  32. the TCPLUS-L mailing list.  To subscribe, send mail to
  33. listserv@ucf1vm.cc.ucf.edu containing the line "subscribe tcplus-l
  34. Your Name".  I'll send you a copy of my BC++ 3.1.  If anyone else
  35. wants them, just email me.
  36.  
  37. The workaround (that possibly works under gcc too) is to instantiate
  38. the first template before the compiler sees the full definition of the
  39. "forward declared" templates.  So, add at line "//here" above
  40.     typedef A<int> Hack_Aint;
  41.     typedef A<double> Hack_Adouble;
  42.     //...instantiate any other A<T>s you'll be using in your program...
  43.  
  44. A hassle, but better than no templates at all.  Let me know if there's
  45. any problems.
  46.  
  47. Jamshid Afshar
  48. jamshid@emx.utexas.edu
  49.