在提升文档中:
0.00028012130615107805 0.00021391570000183283
0.0005697194131890626 0.0006458197694718355
0.00014415554662672425 0.00015479059187195545
0.00021391570000183283 0.00021391570000541633
0.00015479059187195545 0.00015479059186527505
0.0006458197694718355 0.0006458197694718355
为什么我们需要& xyz :: foo,而不仅仅是xyz :: foo?
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
通过这种方式,我们不使用&。
答案 0 :(得分:4)
运算符地址(即&
)必须获取指向成员函数的指针。对于non-member function,由于function-to-pointer隐式转换,它是可选的。
可以使用非成员函数的地址或静态成员函数初始化指向函数的指针。由于函数到指针的隐式转换,address-of运算符是可选的: