问题描述
我一直认为函数指针不需要和号:
I've always believed that function pointers don't require an ampersand:
然而,我看到的每个例子使用 boost :: bind
显示一个,而且在大多数情况下,我的编译器如果省略它,会给出一个通常不可更改的错误消息。
Yet, every example I've seen of using boost::bind
shows one, and my compiler - in most situations - gives a typically inscrutable error message if it's omitted.
synchronize(boost::bind(&Device::asyncUpdate , this, "ErrorMessage")); // Works
synchronize(boost::bind(Device::asyncUpdate , this, "ErrorMessage")); // Fails
假设 boost :: bind
的第一个参数基本上是函数指针?
Am I wrong in assuming that boost::bind
's first parameter is basically function pointer?
推荐答案
函数指针不需要它,成员函数指针。
Function pointers don't need it, member function pointers do.
Device :: asyncUpdate
是成员函数,因为你可以猜到,因为它被绑定到这
。
Device::asyncUpdate
is member function, as you could guess because it is being bound to this
.
这是从n3337,5.3.1 / 4的规范性引文
Here's a normative quote from n3337, 5.3.1/4
这篇关于如果函数指针不需要和号,为什么boost :: bind需要一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!