On 19 avr, 18:18, "barcaroller" <barcarol...@music.netwrote:
What are proxy objects used for in C++? Currently, the only
use of proxy objects I know of is that one can write one-liner
code such as:
myobj.foo() (a,b) (c,d) (e,f) ;
where myobj.foo() returns a proxy object with an overloaded
operator() member function, which returns a reference to the
proxy object itself. But writing one-liners cannot be reason
enough to use proxy objects.
The two most frequent reasons I know of are for context
dependent implicit type conversions (where the proxy has a:
template< typename T Proxy::operator T() const
function), and for distinguishing between lvalue and rvalue
accesses (where the proxy will have an implicit conversion to
the target type for rvalue accesses, and an operator= which
modifies the source, rather than the proxy, for lvalue
accesses).
I don't think I've ever seen a proxy used as you've described.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34