
Douglas Gregor wrote:
On Thursday 11 March 2004 06:14 am, Peter Dimov wrote:
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.
Yes, I understand the Long-Term Goal (if not its utmost importance), but your approach doesn't scale to other function<>-like entites. void f(); my_function<void()> g(f); your_function<void()> h(g); g == h; //??? g.contains(h); // false h.contains(g); // true It's limited to the one and only function<> (and you can't even ask a function<> whether it contains another function<>, right?)