Thread View: comp.std.c++
1 messages
1 total messages
Started by Atman Binstock
Fri, 20 Oct 1995 16:45
differences in op-> and op*
Author: 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads