From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-03-11 06:14:50
Douglas Gregor wrote:
> We can have boost::function_equal(f, g), but I'd prefer that it
> always use operator==. Then boost::lambda, boost::bind, etc. can just
> overload function_equal.
That's what I had in mind when I posted; sorry for not mentioning it, but I
didn't want to influence the answers. Am I not evil.
In summary, unqualified function_equal(f, g), with a default implementation
that returns f == g.
> Why? Because most users just want to write a
> normal operator== and have it work; that's what makes sense. Just
> because Lambda can do some screwy things with syntax (and believe me,
> I love Lambda) doesn't mean others should have to use a weird
> comparison syntax.
I note that you show some pro-== bias. function_equal (my original name was
fn_equal, but I can live with either) is not the same as ==, even though it
does use == by default. Placeholders, reference_wrapper, tuple all respond
differently to fn_equal and ==.
In fact, I still think that your decision to expose the 'f contains g'
operation under the f == g notation is a mistake, too. 'contains' is not
'==', either; it is asymmetric, as it is possible for f to contain g but not
In short, == for function objects is an illusion and it must die, Herb
Sutter's influential articles notwithstanding.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk