home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!cv3!dschieb
- From: dschieb@muse.cv.nrao.edu (Darrell Schiebel)
- Subject: template specialization (Not up to task, Suggestions?)
- Message-ID: <DSCHIEB.93Jan6094110@muse.cv.nrao.edu>
- Sender: news@nrao.edu
- Organization: National Radio Astronomy Observatory
- Distribution: comp
- Date: Wed, 6 Jan 1993 14:41:10 GMT
- Lines: 78
-
-
- I posted a question yesterday about specialization of a constructor
- based on a template:
-
- template<class t> class id {
- public:
- id();
- };
-
- template<class t> class users {};
-
- I would like to specialize the constructor of "id" for all "users", something
- along the lines of:
-
- template<class t> inline id<users<t> >::id() {}
-
- However, I've either not been able to get the syntax right or this is not
- currently possible with cfront 3.0 compatible compilers. Does anyone
- have any suggestions, or work-arounds?? Anyone ever tried this?? Below is
- my test file of variation I've tried, along with the error messages.
-
- Thanks for any help,
- Darrell Schiebel
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- template<class t> class id {
- public:
- id();
- };
-
- template<class t> class users {};
-
-
- //line 12: qualifier parameters must match the template formal parameters
- #if T1
- template<class t> inline id<users<t> >::id() {}
- #endif
- //line 16: template users argument mismatch, the template formal: t required a type actual parameter
- #if T2
- template<class users<t> > inline id<users<t> >::id() {}
- #endif
- //line 21: empty template parameter list
- //line 21: type expected for t -- did you misdeclare a template?
- #if T3
- inline id<template<class t> users >::id() {}
- #endif
- //line 26: empty template parameter list
- //line 26: type expected for t -- did you misdeclare a template?
- #if T4
- inline id<template<class t> users<t> >::id() {}
- #endif
- //line 31: empty template parameter list
- //line 31: type expected for t -- did you misdeclare a template?
- #if T5
- inline id<template<class t> class users >::id() {}
- #endif
- //line 36: empty template parameter list
- //line 36: type expected for t -- did you misdeclare a template?
- #if T6
- inline id<template<class t> class users<t> >::id() {}
- #endif
- //line 43: syntax error -- did you forget a ';'?
- //line 43: sorry, not implemented: forward declaration of a specialized version of template users
- //line 43: class users <any > -- did you mean a general forward declaration of the template?
- //line 43: if so, use: template <formal-parameters> class users;
- #if T7
- typedef userstype template<class t> class users<t>;
- #endif
- //line 47: syntax error -- did you forget a ';'?
- #if T8
- typedef userstype template<class t> class users;
- #endif
-
-
- main(){}
-
-
-
-