home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!cv3!dschieb
- From: dschieb@muse.cv.nrao.edu (Darrell Schiebel)
- Subject: template disappointments ... (suggestions?)
- Message-ID: <DSCHIEB.92Dec29133556@muse.cv.nrao.edu>
- Sender: news@nrao.edu
- Organization: National Radio Astronomy Observatory
- Distribution: comp
- Date: Tue, 29 Dec 1992 18:35:56 GMT
- Lines: 53
-
-
- I am fairly disappointed with the template implementation in Sun's SC2.0.1
- (and cfront 3.0 (I suppose)). So far two things are particularly annoying:
-
- (1) The inability to derive templated classes from a non-templated
- base class of the same name:
- class typeinfo {};
- template<class t> class typeinfo : public typeinfo {};
-
- (2) but worse than this minor item, it seems as though it is
- impossible to compose templates from templates:
- template<class t> class vector {};
- template<class t> class list {};
-
- list<vector<int>> list_vec_int;
-
- certainly various kludges will work some of the time:
-
- typedef vector<int> fred;
- list<fred> list_vec_int;
-
- it is certainly unfortunate that one must enumerate each
- of the templated expansions via typedefs in order to be able
- to use them in other templates. In addition this is not always
- possible:
-
- class typeinfo {};
- template<class t> class typeinfo_ : public typeinfo {};
- template<class t> class vector {};
-
- template<class t> const typeinfo *typeid(vector<t> *) {
- static typeinfo_<vector<t>> *storedId = 0;
- ^^^^^^^^^
- one gets a error like:
- "test3.C", line 110: error: type expected for name
-
- Try our little trick from before:
-
- template<class t> const typeinfo *typeid(vector<t> *) {
- typedef vector<t> fred;
- static typeinfo_<fred> *storedId = 0;
-
- And one gets:
- "test3.C", line 102: sorry, not implemented: local typedef fred within template function
-
- I was afraid that the implementors would end up making template second class.
- I think I was better off with TI's cpp. Does anyone have any suggestions?
- I haven't finished reading all of the documentation so I could have missed
- something. Thanks for any suggestions.
-
-
- Darrell Schiebel
- (dschieb@nrao.edu)
-