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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!titan!cetra!lightw
  3. From: lightw@cetra.trl.OZ.AU (Liron Lightwood)
  4. Subject: RE: C++ 3.01 templates problem.
  5. Message-ID: <1993Jan13.054055.23537@trl.oz.au>
  6. Summary: It's a bug!
  7. Keywords: C++ templates bug
  8. Sender: root@trl.oz.au (System PRIVILEGED Account)
  9. Organization: Telecom Research Labs, Melbourne, Australia
  10. Date: Wed, 13 Jan 1993 05:40:55 GMT
  11. Lines: 53
  12.  
  13. Earlier I posted a problem regarding a possible bug with C++ 3.01
  14. templates, in which the following compiler error occurs.
  15.  
  16. ---
  17. "/usr/users/lightw/IN/src/SMS/mgmt/a.c", line 25: error: bad argument  1 type for  GetFunc <x, int >::GetFunc__pt__4_1xi(): int (x::*)() ( int (x::*)() expected)
  18. ---
  19.  
  20. I have received several mail replies indicating that this is a bug in 
  21. cfront 3.01!!!  They said that it is fixed in cfront 3.0.2.  Is this
  22. available?
  23.  
  24. I have also been told that the problem extends to other uses of function
  25. pointers inside template classes.  For example, assining such a pointer to
  26. 0.
  27.  
  28. Thanks to all those who have replied.
  29.  
  30. P.S.  Here is the reprint of the code which causes the bug.
  31. -----------------------------
  32.  
  33. class x  
  34. {
  35.     public:
  36.     int x_int() { return 21; }
  37.          // fff is a member function of class x which returns an
  38.          // integer
  39. };
  40.  
  41. int ft()
  42. {
  43.     return 22;
  44. }
  45.  
  46. template <class A,class B> class GetFunc {
  47. public:  
  48.    B (A::*a_b_func)();  
  49.         // func contains address of a member function of class B 
  50.         // (e.g. class x) which returns an A (e.g. an int)    
  51.  
  52.    GetFunc(B (A::*f)()) : a_b_func(f) {}  // constructor
  53. };
  54.  
  55. main()   
  56. {
  57.     GetFunc<x,int> getfunc_x_int ( &(x::x_int) ); 
  58. }
  59.  
  60. ---------------------------------------------------
  61.  
  62. Liron Lightwood                     Internet : r.lightwood@trl.oz.au
  63. Telecom Research Laboratories       Phone : +61 3 253 6535
  64. 770 Blackburn Road                  Snail : P.O. Box 249 Clayton 3168 Australia
  65. Clayton  Vic. 3168 Australia        Disclaimer : My views are not my company's
  66.