Item 30 of Scott Meyers' "more effective C++" maps out a 'proxy object' programming design-pattern.
The problem is if you have:
X x;
x[3]=42;
cout<<x[3]
... you need X's operator[] overload to be able to distinguish between L-value and R-value use.
(maybe you need different code to run,e.g. in the first case heavy copying might be involved, but in the second case maybe we can just pass back a reference).
The proxy pattern is that X contains a Proxy class, and X's operator[] overloads return an object of type Proxy.
So that code becomes:
X x;
{some Proxy object}=42;
cout<<{some Proxy object}
Now we just have to give our Proxy object an override for "operator=", which handles the first case, and an override for 'conversion to std::string or char*' which handles the second.
And C++'s attempt to find an appropriate type conversion will trigger the relevant override.
However, this book was written before C++11, and one of the main features of C++11 is a new && (R-value reference) operator.
Is there now a simpler way of coding separate R-value and L-value assignments?
Is this proxy-object design-pattern now obsolete?