home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18751 < prev    next >
Encoding:
Text File  |  1993-01-06  |  2.7 KB  |  90 lines

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: dschieb@muse.cv.nrao.edu (Darrell Schiebel)
  4. Subject: template specialization (Not up to task, Suggestions?)
  5. Message-ID: <DSCHIEB.93Jan6094110@muse.cv.nrao.edu>
  6. Sender: news@nrao.edu
  7. Organization: National Radio Astronomy Observatory
  8. Distribution: comp
  9. Date: Wed, 6 Jan 1993 14:41:10 GMT
  10. Lines: 78
  11.  
  12.  
  13. I posted a question yesterday about specialization of a constructor
  14. based on a template:
  15.  
  16.     template<class t> class id {
  17.     public:
  18.       id();
  19.     };
  20.  
  21.     template<class t> class users {};
  22.  
  23. I would like to specialize the constructor of "id" for all "users", something
  24. along the lines of:
  25.  
  26.     template<class t> inline id<users<t> >::id() {}
  27.  
  28. However, I've either not been able to get the syntax right or this is not
  29. currently possible with cfront 3.0 compatible compilers. Does anyone
  30. have any suggestions, or work-arounds?? Anyone ever tried this?? Below is
  31. my test file of variation I've tried, along with the error messages.
  32.  
  33.                     Thanks for any help,
  34.                     Darrell Schiebel
  35. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  36.  
  37. template<class t> class id {
  38. public:
  39.   id();
  40. };
  41.  
  42. template<class t> class users {};
  43.  
  44.  
  45. //line 12: qualifier parameters must match the template formal parameters
  46. #if T1
  47. template<class t> inline id<users<t> >::id() {}
  48. #endif
  49. //line 16: template users argument mismatch, the template formal: t required a type actual parameter
  50. #if T2
  51. template<class users<t> > inline id<users<t> >::id() {}
  52. #endif
  53. //line 21: empty template parameter list
  54. //line 21: type expected for t -- did you misdeclare a template?
  55. #if T3
  56. inline id<template<class t> users >::id() {}
  57. #endif
  58. //line 26: empty template parameter list
  59. //line 26: type expected for t -- did you misdeclare a template?
  60. #if T4
  61. inline id<template<class t> users<t> >::id() {}
  62. #endif
  63. //line 31: empty template parameter list
  64. //line 31: type expected for t -- did you misdeclare a template?
  65. #if T5
  66. inline id<template<class t> class users >::id() {}
  67. #endif
  68. //line 36: empty template parameter list
  69. //line 36: type expected for t -- did you misdeclare a template?
  70. #if T6
  71. inline id<template<class t> class users<t> >::id() {}
  72. #endif
  73. //line 43: syntax error -- did you forget a ';'?
  74. //line 43: sorry, not implemented: forward declaration of a specialized version of template users
  75. //line 43: class   users <any > -- did you mean a general forward declaration of the template?
  76. //line 43: if so, use:  template <formal-parameters> class users;
  77. #if T7
  78. typedef userstype template<class t> class users<t>;
  79. #endif
  80. //line 47: syntax error -- did you forget a ';'?
  81. #if T8
  82. typedef userstype template<class t> class users;
  83. #endif
  84.  
  85.  
  86. main(){}
  87.  
  88.  
  89.  
  90.