2

Consider the std::function instances below, where some of them (not all) encapsulate member functions of a certain class. I want to compare those instances and identify all, which point to the same function as well as the same instance:

#include <functional>

typedef std::function<void(int)> myfun;

class Foo{
public:
    void foo(int i){/*...*/}
    myfun getFun(){
        return std::bind(&Foo::foo, *this,std::placeholders::_1);
    }
};

void test(){
    Foo f1, f2;
    myfun p1 = f1.getFun(), p2 = f2.getFun(), p3 = f2.getFun(), p4 = [](int i){};
    //how do I compare p1 - p4, so that p1 != p2,p3,p4, p2 == p3, p4 != p3,p2,p1
}

Do you have any idea if (and how) this is possible?

muffel
  • 7,004
  • 8
  • 57
  • 98
  • 1
    http://stackoverflow.com/questions/3629835/why-is-stdfunction-not-equality-comparable – stijn Apr 25 '14 at 08:59

0 Answers0