
On Thursday 11 March 2004 06:14 am, Peter Dimov wrote:
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 vice versa.
In short, == for function objects is an illusion and it must die, Herb Sutter's influential articles notwithstanding.
Opinion noted :) The primary reason for using operator== is that it models what function pointers do, and makes function<> a near-complete drop-in replacement for function pointers. That's been my goal for a Very Long Time. The question is whether the ambiguities it brings outweigh the benefits of having a function-pointer---like syntax. Doug