Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-07-13 14:52:03


Richard Smith <richard_at_[hidden]> writes:

> David Abrahams wrote:
>
>> Richard Smith <richard_at_[hidden]> 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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk