Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Proxy objects...

Reply
Thread Tools

Proxy objects...

 
 
barcaroller
Guest
Posts: n/a
 
      04-19-2008

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.




 
Reply With Quote
 
 
 
 
Kai-Uwe Bux
Guest
Posts: n/a
 
      04-19-2008
barcaroller wrote:

>
> 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 following come to mind:

a) Matrix classes which support [][] notation have an operator[] which
returns a proxy.

b) std::vector<bool> uses proxy objects instead of references (since those
won't do the trick).

c) String classes and the like might return proxy objects (e.g., for
operator[]) instead of references in order to avoid/solve aliasing
problems. This can be useful for COW and reference counted implementations.


Best

Kai-Uwe Bux
 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      04-19-2008
On 19 avr, 18:18, "barcaroller" <(E-Mail Removed)> wrote:
> 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:perator 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:(E-Mail Removed)
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
 
Reply With Quote
 
barcaroller
Guest
Posts: n/a
 
      04-19-2008

"James Kanze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I don't think I've ever seen a proxy used as you've described.


boost:rogram_options

Example:

options_description desc("Allowed options");

desc.add_options()
("help", "help message")
("level", value<int>(), "set level");



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Proxy pattern and java.lang.reflect.Proxy/InvocationHandler Karsten Wutzke Java 1 08-20-2007 11:05 AM
Facebook Proxy | MySpace Proxy 35085675@qq.com Java 0 08-14-2007 06:35 AM
Inbound Proxy and Outbound Proxy chellappa VOIP 0 04-07-2006 10:58 AM
Press Release: Scalable SIP Proxy and RTP Media Proxy for NAT traversal sales@lanscapecorp.com VOIP 1 01-23-2006 06:32 PM
Help to set up tomcat 4.1.27 behind socks proxy to access database outside the proxy vidy5300 Java 0 06-07-2004 02:23 PM



Advertisments