【发布时间】:2017-11-28 15:05:55
【问题描述】:
这是一个玩具示例
#include <iostream>
#include <functional>
struct Obj
{
int x;
int foo()
{
return 42;
}
};
int main()
{
Obj a, b;
std::function<int()> f1 = std::bind(&Obj::foo, &a);
std::function<int()> f2 = std::bind(&Obj::foo, &b);
std::function<int()> f3 = std::bind(&Obj::foo, &a);
std::function<int()> f4 = std::bind(&Obj::foo, &b);
}
如何验证f1 == f3 和f2 == f4,这里的== 比较器表示两个std::function 对象对应同一个对象的相同方法?
【问题讨论】:
标签: c++ c++11 std-function stdbind