home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!ubc-cs!destroyer!sol.ctr.columbia.edu!usc!cs.utexas.edu!hellgate.utah.edu!fcom.cc.utah.edu!swillden
- From: swillden@news.ccutah.edu (Shawn Willden)
- Newsgroups: comp.lang.c++
- Subject: BC++ templates broken
- Message-ID: <1992Aug29.212548.8071@fcom.cc.utah.edu>
- Date: 29 Aug 92 21:25:48 GMT
- Sender: news@fcom.cc.utah.edu
- Organization: University of Utah Computer Center
- Lines: 40
- X-Newsreader: Tin 1.1 PL3
-
- Hi all,
-
- I have discovered a problem with BC++'s templates. Given code like
- this:
-
- template<class T> class A1;
- template<class T> class A2;
-
- template<class T> class A { A1* a; A2* b; };
- template<class T> class A1 : public A<T> {};
- template<class T> class A2 : public A<T> {};
-
- main() {A1<int> myA1;}
-
- the compiler chokes, complaining that it cannot expand A2<int> because A<int>
- is not yet defined. Apparently, the expansion of A1<int> causes the expansion
- of A<int> which in turn causes the expansion of A2<int> (due to the declaration
- of A's member b) but it *can't* expand A2<int> because A<int> hasn't been
- expanded yet. Unfortunately, I have to do this. As I see it, these are my
- options:
-
- 1) 'untemplate' these classes, make them deal with
- void*'s instead of T*'s and do lots of icky casts.
- I *can* do this because these classes are only used
- internally by another class, which is a template and
- could insure type-safety.
- 2) Make A::a and A::b A*'s and provide lots of forwarding
- functions and do lots of fugly downcasting.
- 3) Make the compiler swallow the above code somehow.
- 4) Redesign the class that uses these three (several
- hundred lines of code, none of it mine and all of
- it ugly - this option does *not* appeal to me.)
- 5) Get a job as a garbage man so I can just chuck
- people's trash instead of having to fix it :-)
-
- Obviously, option 3 is what I really want. Any ideas?
-
- --
- Shawn Willden
- swillden@icarus.weber.edu
-