|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-03-10 17:53:51
On Wednesday 10 March 2004 07:41 am, Peter Dimov wrote:
> Douglas Gregor wrote:
> > I'd think that this is the right expectation for Lambda, but not for
> > FC++ or Bind. Not that I'm helping any :)
>
> No, I don't think so. Expressions that are valid for both Bind and Lambda
> should have the same semantics. And in fact, this is not just theory:
Having Lambda's == and != operators return function objects convertible to
bool would keep Lambda's semantics a superset of Bind's semantics.
> >> More generally, I think it's not a good idea to try to create
> >> "function equality" with operator==. I didn't participate in any of
> >> the earlier discussions, but I think that if you want to
> >> register/unregister function objects with an event handler, for
> >> instance, you should use a separate "handle" object to keep track of
> >> "function object identity".
> >
> > The problem is that there are a whole lot of use cases for equality of
> > function objects, and people really want them. The especially want
> >
> > delegate<void()> f;
> > f += some_function_object; // connect
> > f -= some_function_object; // disconnect
>
> There is no mention of operator== anywhere in the above, though.
Right. The basic idea of "-=" is that it uses == to find connected targets
equal to some_function_object and disconnects them. Of course, it could use
function_equal or anything else, but I do feel that == is most natural.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk