История изменений
Исправление quasimoto, (текущая версия) :
но как только лямбда начинает замыкать она перестаёт нормально приводиться к обычному указателю на функцию
И аналогично для std::function.
handler.cc: In member function ‘void Class::signal_(std::function<void(int)>, int
)’:
handler.cc:367:69: error: cannot convert ‘std::function<void(int)>’ to ‘__sighand
ler_t {aka void (*)(int)}’ for argument ‘2’ to ‘void (* signal(int, __sighandler_
t))(int)’
In file included from handler.cc:363:0:
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:
In static member function ‘static void std::_Function_handler<void(_ArgTypes ...)
, _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes ...) [with _Functor = std
::_Bind<std::_Mem_fn<void (Class::*)(int)>(Class*)>, _ArgTypes = {int}]’:
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:2
148:6: instantiated from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor
, typename std::enable_if<(! std::is_integral<_Functor>::value), std::function<_R
es(_ArgTypes ...)>::_Useless>::type) [with _Functor = std::_Bind<std::_Mem_fn<voi
d (Class::*)(int)>(Class*)>, _Res = void, _ArgTypes = {int}, typename std::enable
_if<(! std::is_integral<_Functor>::value), std::function<_Res(_ArgTypes ...)>::_U
seless>::type = std::function<void(int)>::_Useless]’
handler.cc:375:58: instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:1
778:2: error: no match for call to ‘(std::_Bind<std::_Mem_fn<void (Class::*)(int)
>(Class*)>) (int)’
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:1
130:11: note: candidates are:
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:1
201:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor
(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}, _Result =
_Result, _Functor = std::_Mem_fn<void (Class::*)(int)>, _Bound_args = {Class*}]
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:1
215:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor
(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}, _Res
ult = _Result, _Functor = std::_Mem_fn<void (Class::*)(int)>, _Bound_args = {Clas
s*}]
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:1
229:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor
(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}, _
Result = _Result, _Functor = std::_Mem_fn<void (Class::*)(int)>, _Bound_args = {C
lass*}]
/usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/functional:1
243:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor
(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args .
..}, _Result = _Result, _Functor = std::_Mem_fn<void (Class::*)(int)>, _Bound_arg
s = {Class*}]
блин, они же всё равно создают замыкание, почему бы не дать обычный сишный указатель на неё.
Исходная версия quasimoto, :
но как только лямбда начинает замыкать она перестаёт нормально приводиться к обычному указателю на функцию
И аналогично для std::function.