home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16444 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.7 KB  |  38 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!spool.mu.edu!umn.edu!csus.edu!borland.com!pete
  3. From: pete@borland.com (Pete Becker)
  4. Subject: Re: Operator -> cannot return non-class types?
  5. Message-ID: <1992Nov17.165841.13644@borland.com>
  6. Originator: pete@genghis.borland.com
  7. Sender: news@borland.com (News Admin)
  8. Organization: Borland International
  9. References: <b5327e91@aut.abb.se> <a008546a@p3.f6.n249.z2.fidonet.org> <1992Nov17.131437.1@vax1.bham.ac.uk>
  10. Date: Tue, 17 Nov 1992 16:58:41 GMT
  11. Lines: 25
  12.  
  13. In article <1992Nov17.131437.1@vax1.bham.ac.uk> mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
  14. >
  15. >The _real_ question is not _does_ the restriction exist but _why_ does
  16. >it exist? One clealy couldn't _use_ an operator->() returning anything else.
  17. >BUT there can be good reason for a template class to have an operator->()
  18. >that would only be usable for some values of the template parameter.
  19. >
  20. >template <class T> PtrClass { T* operator->();};
  21. >
  22. >I now fully support the original poster's assertion that this restriction
  23. >should be lifted now that the language has templates.
  24.  
  25.     I must have missed something, because I don't see the connection
  26. between the use of operator->() and templates.  Yes, you ought to be able to
  27. use operator->() in a template.  The fact that there are types for which
  28. such use would be illegal doesn't seem particularly important, unless, of
  29. course, you attempt to instantiate the template for one of those types, in 
  30. which case you have a programming error which the compiler ought to 
  31. diagnose.
  32.     Is the claim here that the possibility that the template could be used
  33. incorrectly makes the template definition illegal?  If so, get yourself a
  34. different compiler.
  35.     -- Pete
  36.  
  37.  
  38.