
Richard Smith <richard@ex-parrot.com> writes:
David Abrahams wrote:
Richard Smith <richard@ex-parrot.com> writes:
[...]
it is legal to call non-const member functions on the value returned from operator*:
struct foo { void non_const(); };
my_iterator<foo> i; (*i).non_const();
No. The value returned from operator* might be a const proxy with a (const) conversion operator to value_type.
That's an interesting point. If operator* returns a proxy type, as operator. cannot be overloaded, (*a).m will always call a member of the proxy type, so for a->m to be equivalent, the operator-> should return (probably by proxy) a pointer to the operator* proxy type.
No, we only have to make the proxy's members inaccessible, and then the precondition for supplying operator-> goes away and we can make it do anything reasonable. -- Dave Abrahams Boost Consulting www.boost-consulting.com