home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!spool.mu.edu!umn.edu!csus.edu!borland.com!pete
- From: pete@borland.com (Pete Becker)
- Subject: Re: Operator -> cannot return non-class types?
- Message-ID: <1992Nov17.165841.13644@borland.com>
- Originator: pete@genghis.borland.com
- Sender: news@borland.com (News Admin)
- Organization: Borland International
- References: <b5327e91@aut.abb.se> <a008546a@p3.f6.n249.z2.fidonet.org> <1992Nov17.131437.1@vax1.bham.ac.uk>
- Date: Tue, 17 Nov 1992 16:58:41 GMT
- Lines: 25
-
- In article <1992Nov17.131437.1@vax1.bham.ac.uk> mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
- >
- >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.
-
- I must have missed something, because I don't see the connection
- between the use of operator->() and templates. Yes, you ought to be able to
- use operator->() in a template. The fact that there are types for which
- such use would be illegal doesn't seem particularly important, unless, of
- course, you attempt to instantiate the template for one of those types, in
- which case you have a programming error which the compiler ought to
- diagnose.
- Is the claim here that the possibility that the template could be used
- incorrectly makes the template definition illegal? If so, get yourself a
- different compiler.
- -- Pete
-
-
-