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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!agate!doc.ic.ac.uk!mrccrc!warwick!bham!bhamvx!mccauleyba
  3. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  4. Subject: Re: Operator -> cannot return non-class types?
  5. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  6. Message-ID: <1992Nov17.131437.1@vax1.bham.ac.uk>
  7. Date: Tue, 17 Nov 1992 13:14:37 GMT
  8. Lines: 33
  9. References: <b5327e91@aut.abb.se> <a008546a@p3.f6.n249.z2.fidonet.org>
  10. Organization: University of Birmingham
  11.  
  12. In article <a008546a@p3.f6.n249.z2.fidonet.org>, Gilles_Kohl@spam.fido.de (Gilles Kohl) writes:
  13. >  > What is the rationale behind this restriction? I couldn't find anything
  14.                  ^^^^^^^^^
  15. >  > in C++PL 2nd ed. that mentions this restriction, although I didn't look too
  16. >  > hard.
  17. > Daniel,
  18. > I think the following on page 594 of C++PL2 applies:
  19. > r.13.4.6 Class Member Access
  20. > (...) An expression x->m is interpreted as (x.operator->())->m for a class 
  21. > object x. It follows that operator-> must return either a pointer to a class or 
  22. > an object of or a reference to a class for which operator->() is defined. 
  23. > operator->() must be a nonstatic member function.
  24. I think you've lost the thread of this thread.
  25. (I gave roughly the above reply last week :-) )
  26. The _real_ question is not _does_ the restriction exist but _why_ does
  27. it exist? One clealy couldn't _use_ an operator->() returning anything else.
  28. BUT there can be good reason for a template class to have an operator->()
  29. that would only be usable for some values of the template parameter.
  30.  
  31. template <class T> PtrClass { T* operator->();};
  32.  
  33. I now fully support the original poster's assertion that this restriction
  34. should be lifted now that the language has templates.
  35. -- 
  36.     \\   ( )    No Bullshit!     |  Email: B.A.McCauley@bham.ac.uk   
  37.  .  _\\__[oo        from         |  Voice: +44 21 471 3789 (home)
  38. .__/  \\ /\@    /~)  /~[   /\/[  |    Fax: +44 21 625 2175 (work)
  39. .  l___\\      /~~) /~~[  /   [  |  Snail: 197 Harborne Lane,
  40.  # ll  l\\    ~~~~ ~   ~ ~    ~  |         Birmingham, B29 6SS, UK
  41. ###LL  LL\\   (Brian McCauley)   |   ICBM: 52.5N 1.9W
  42.