1

I want to be able to compare variables that hold functions to see if the function they hold is the same or not.

#include <iostream>
#include <functional>

using namespace std;

typedef std::function<void(void)> func;

void sayHi() {
    cout << "hi" << endl;
}

int main() {
    func f1 = bind(&sayHi);
    func f2 = bind(&sayHi);

    cout << (f1 == f2) << endl; // IntelliSense states there is no "==" 
                               //   operator to match these operands
}

I'm guessing there is some way to use the operator keyword to implement an equality matching expression? I really don't know how to go about implementing it in this case though.

Jazcash
  • 3,145
  • 2
  • 31
  • 46

0 Answers0