Article View: comp.std.c++
Article #2270differences in op-> and op*
From: Atman Binstock
Date: Fri, 20 Oct 1995 16:45
Date: Fri, 20 Oct 1995 16:45
43 lines
1912 bytes
1912 bytes
Could someone possibly tell me why there is a difference in the
functionality of user-defined operators "->" and "*"?
from: 13.5.6 Class member access [over.ref]
>1 operator-> shall be a non-static member function taking no parameters.
> It implements class member access using ->
> postfix-expression -> id-expression
> An expression x->m is interpreted as (x.operator->())->m for a class
> object x of type T if T::operator->() exists and if the operator is
> selected as the best match function by the overload resolution mechaΓ
> nism (_over.match_).
Wheras *x is not interpreted as *(x.operator*()) as far as I can tell
(the april WP does not seem to talk about unary operator*() much).
Why is there this difference?
Also, the ARM (13.4.6) added:
> 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.
Does this still hold under the draft standard?
If so, does it follow given:
T* f();
that:
class X { T* operator->() { return f(); } };
is always does the same as:
class X { T& operator-:() { return *f(); } };
assuming that T does not have user-defined operator*
Thanks for any help on this matter,
Atman Binstock
ajb@panix.com
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<468gfs$26d@panix.com>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: ajb@panix.com (Atman Binstock) Newsgroups: comp.std.c++ Subject: differences in op-> and op* Date: 20 Oct 1995 16:45:29 GMT Organization: PANIX Public Access Internet and UNIX, NYC Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <468gfs$26d@panix.com> NNTP-Posting-Host: physics2.berkeley.edu