home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12587 < prev    next >
Encoding:
Text File  |  1992-08-19  |  1.7 KB  |  59 lines

  1. Path: sparky!uunet!mcsun!uknet!doc.ic.ac.uk!ibmassc!yktnews!admin!yktnews!victor
  2. From: victor@watson.ibm.com (Victor Miller)
  3. Newsgroups: comp.lang.c++
  4. Subject: intelligent generation of template instances
  5. Message-ID: <VICTOR.92Aug19163324@terse4.watson.ibm.com>
  6. Date: 19 Aug 92 20:33:24 GMT
  7. Sender: news@watson.ibm.com (NNTP News Poster)
  8. Reply-To: victor@watson.ibm.com
  9. Organization: IBM, T.J. Watson Research Center
  10. Lines: 45
  11. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  12. Nntp-Posting-Host: terse4.watson.ibm.com
  13.  
  14. Suppose that I have a template class (taken from the FAQ):
  15.  
  16.      template<class T>
  17.      class Vec {
  18.        int  xlen;
  19.        T*   xdata;
  20.        int  check(int i) const;
  21.      public:
  22.        int len() const {
  23.          return xlen;
  24.        }
  25.        const T&  operator[](int i) const {
  26.          return xdata[check(i)];
  27.        }
  28.        T&  operator[](int i) {
  29.          return xdata[check(i)];
  30.        }
  31.        Vec(int L=10) :
  32.        xlen(L),
  33.        xdata(new T[L]) {
  34.          /*verify*/
  35.        }
  36.        ~Vec() {
  37.          delete [] xdata;
  38.        }
  39.      };
  40.  
  41. If I have the actual definintion of check in a separate file.  It
  42. appears that I need to manually instantiate each instance that I use.
  43. Is there any sort of hack which would allow automatic generation of
  44. all such instances after looking at the results of compilations?
  45.  
  46. For instance after a lot of programs use the Vec class, it would be
  47. nice if a post-processor could determine that the instances (for
  48. example) of Vec<int>, Vec<float> and Vec<char *> where used, and
  49. compile them (sounds like a job for a makefile)?  Does anyone know of
  50. such a program (say on Unix)?
  51.  
  52.  
  53. --
  54.         Victor S. Miller
  55.         Bitnet: VICTOR at WATSON
  56.         Internet: victor@watson.ibm.com
  57.         IBM, TJ Watson Research Center
  58.         "Great artists steal; lesser artists borrow" Igor Stravinsky
  59.