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