Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-03-10 00:08:30

On Tuesday 09 March 2004 05:26 pm, Brian McNamara wrote:
> In my opinion,
> lambda(x) { return f(x) == g(x) }.
> is best. Whenever I see a placeholder, I expect the whole expression
> (modulo operator precedence and "constant(foo)" issues) to get
> lambda-ized, and thus I expect operator== to create a lambda
> expression. (I dunno if this is the 'right' expectation to have, given
> the way the libraries work now, but I think it is a reasonable/simple
> 'ideal' expectation.)

I'd think that this is the right expectation for Lambda, but not for FC++ or
Bind. Not that I'm helping any :)

> 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

> (The whole idea of "f==g" being meaningful for two functions is a little
> bit fishy to me, but this is probably more of a personal bias than
> anything I can defend objectively.)

I held to that philosophy for a long time, but the use cases are stacked
against us :)


Boost list run by bdawes at, gregod at, cpdaniel at, john at