1
在升压DOC:为什么我们需要在boost中绑定成员函数?
Binding member functions can be done similarly. A bound member function takes in a pointer or reference to an object as the first argument. For instance, given:
struct xyz
{
void foo(int) const;
};
xyz's foo member function can be bound as:
bind(&xyz::foo, obj, arg1) // obj is an xyz object
我们为什么需要& XYZ :: foo的,而不仅仅是XYZ :: foo的?
int f(int a, int b)
{
return a + b;
}
std::cout << bind(f, 1, 2)() << std::endl;
以这种方式,我们不使用&。