home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!doc.ic.ac.uk!ibmassc!yktnews!admin!yktnews!victor
- From: victor@watson.ibm.com (Victor Miller)
- Newsgroups: comp.lang.c++
- Subject: intelligent generation of template instances
- Message-ID: <VICTOR.92Aug19163324@terse4.watson.ibm.com>
- Date: 19 Aug 92 20:33:24 GMT
- Sender: news@watson.ibm.com (NNTP News Poster)
- Reply-To: victor@watson.ibm.com
- Organization: IBM, T.J. Watson Research Center
- Lines: 45
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- Nntp-Posting-Host: terse4.watson.ibm.com
-
- Suppose that I have a template class (taken from the FAQ):
-
- template<class T>
- class Vec {
- int xlen;
- T* xdata;
- int check(int i) const;
- public:
- int len() const {
- return xlen;
- }
- const T& operator[](int i) const {
- return xdata[check(i)];
- }
- T& operator[](int i) {
- return xdata[check(i)];
- }
- Vec(int L=10) :
- xlen(L),
- xdata(new T[L]) {
- /*verify*/
- }
- ~Vec() {
- delete [] xdata;
- }
- };
-
- If I have the actual definintion of check in a separate file. It
- appears that I need to manually instantiate each instance that I use.
- Is there any sort of hack which would allow automatic generation of
- all such instances after looking at the results of compilations?
-
- For instance after a lot of programs use the Vec class, it would be
- nice if a post-processor could determine that the instances (for
- example) of Vec<int>, Vec<float> and Vec<char *> where used, and
- compile them (sounds like a job for a makefile)? Does anyone know of
- such a program (say on Unix)?
-
-
- --
- Victor S. Miller
- Bitnet: VICTOR at WATSON
- Internet: victor@watson.ibm.com
- IBM, TJ Watson Research Center
- "Great artists steal; lesser artists borrow" Igor Stravinsky
-