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