qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Sim <g...@redhat.com>
Subject Re: Comparing handles in C++ client
Date Tue, 21 Jun 2011 09:23:31 GMT
On 06/21/2011 09:19 AM, Jiri Krutil wrote:
> Hi
> In the C++ client, things like Receiver appear to be handles with
> pointer semantics.
> Can one compare two handles for equality to find out if they both refer
> to the same implementation object?
> Even if neither class Receiver nor class Handle implement operator==,
> the following code surprisingly complies:
> qpid::messaging::Receiver r1;
> qpid::messaging::Receiver r2;
> ..
> bool equal = (r1 == r2);
> How come this compiles and what does it do?

I believe that is due to the conversion to bool defined for Handle.

At present two handles are equal if either they are both null or if they 
are both non-null. The only time they are not equal is if one is null 
and the other is not.

It would probably make sense to define a slightly more intuitive 
equality operator.

Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org

View raw message