【发布时间】:2013-09-15 13:53:05
【问题描述】:
如果两个函数对象持有相同的函数引用,如何比较?
struct A {
void b(){}
}
int main() {
A a;
auto f1 = std::bind(&A::b, a);
auto f2 = std::bind(&A::b, a);
f1 == f2 // ???
}
【问题讨论】:
-
你从中得到了什么错误?
-
您可以在一定程度上比较
std::function对象(通过function::target)。但是,这不适用于std::bind-表达式,因为它们的类型是实现定义的。