std::function as sighandler_t
问题 How to specify lambda, std::bind result or any other std::function as argument for unix signal function? I'm trying the following std::function<void(int)> handler1 = std::bind(&cancellation_token::cancel, &c); std::function<void(int)> handler2 = [&c](int) { c.cancel(); }; but it doesn't work, because both handler1.target<void(int)>() and handler2.target<void(int)>() return null It works if I initialize handler with free function pointer void foo(int) { ... } std::function<void(int)> handler =