大家好,我最近一直在研究增强信号,因为我想从我自己的自定义代码切换到它来处理信号通知。我从这里编译第一个示例时遇到了问题:http: //www.boost.org/doc/libs/1_53_0/doc/html/signals2/tutorial.html,这里是示例源代码:
struct HelloWorld
{
void operator()() const
{
std::cout << "Hello, World!" << std::endl;
}
};
// Signal with no arguments and a void return value
boost::signals2::signal<void ()> sig;
// Connect a HelloWorld slot
HelloWorld hello;
sig.connect(hello);
// Call all of the slots
sig();
尝试使用以下命令进行编译时出现的问题: clang++ -std=c++11 signals2example.cpp 是这里的错误:
error: no matching function for call to 'get'
func(std::get<indices>(args)...);
为了缩小问题的范围,我注释掉了所有的行,直到我弄清楚是哪一行引起的,它只是简单地说“sig();”的那一行。并且问题似乎与用于元组或其他东西的 std::get 函数有关。关于 boost::signal2 和 clang++ 冲突的在线帖子并不多。我还应该注意,g++ 编译此文档时完全没有抱怨。