c ++ 11信号是否等同于boost.signals

Ash*_*hot -1 c++ boost signals c++11

正如我所说,许多提升库都包含在c ++ 11标准中.更改boost::std::I 之后我设法使用c ++ 11编译器编译它们.我有问题编译包含的代码boost::signals.

#include <iostream> 
#include <functional>
#include <csignal>

void func()
{
    std::cout << "Hello world" << std::endl;
}

int main() 
{ 
    std::signal<void()> s;
    s.connect(func);
    s();      
} 
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

prog.cpp: In function ‘int main()’:
prog.cpp:12:19: error: invalid operands of types ‘void (*(int, __sighandler_t)throw ())(int) {aka void (*(int, void (*)(int))throw ())(int)}’ and ‘void’ to binary ‘operator<’
  std::signal<void()> s;
                   ^
prog.cpp:12:22: error: ‘s’ was not declared in this scope
  std::signal<void()> s; 
Run Code Online (Sandbox Code Playgroud)

std::signal等于boost::signal

nkd*_*kdm 8

std :: signal甚至不是模板,你不能写 std::signal<type>;

http://en.cppreference.com/w/cpp/utility/program/signal

他们是完全不同的东西.boost :: signal是一个信号槽框架,而std :: signal(它来自C,而不是来自C++ 11)是一个设置OS信号处理程序的函数.

  • 还是使用boost :: signals (4认同)