这个boost::lambda::bind用法有什么问题?

这个boost::lambda::bind用法有什么问题?,boost,boost-bind,boost-function,boost-lambda,boost-signals2,Boost,Boost Bind,Boost Function,Boost Lambda,Boost Signals2,这个代码有什么错误吗?我不断收到编译错误。基本上我想连接一个无效返回函数到一个非无效返回类型的信号。 增强版:1.46.1版 #include <boost/signals2.hpp> #include <boost/lambda/bind.hpp> #include <boost/lambda/lambda.hpp> using namespace boost::signals2; void func() { printf("Func called!"

这个代码有什么错误吗?我不断收到编译错误。基本上我想连接一个无效返回函数到一个非无效返回类型的信号。 增强版:1.46.1版

#include <boost/signals2.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
using namespace boost::signals2;

void func()
{
  printf("Func called!");
}

main()
{
  signal<int(int)> sig;
  sig.connect( (boost::lambda::bind(func),  1) );
}
#包括
#包括
#包括
使用名称空间boost::signals2;
void func()
{
printf(“Func called!”);
}
main()
{
信号信号;
sig.connect((boost::lambda::bind(func),1));
}
我在编译时遇到以下错误:

/opt/include/boost/signals2/detail/slot_template.hpp: In member function ‘void boost::signals2::slot1<R, T1, SlotFunction>::init_slot_function(const F&) [with F = int, R = int, T1 = int, SlotFunction = boost::function<int(int)>]’:
/opt/include/boost/signals2/detail/slot_template.hpp:81:9:   instantiated from ‘boost::signals2::slot1<R, T1, SlotFunction>::slot1(const F&) [with F = int, R = int, T1 = int, SlotFunction = boost::function<int(int)>]’
hello-world-example.cpp:13:51:   instantiated from here
/opt/include/boost/signals2/detail/slot_template.hpp:156:9: error: invalid conversion from ‘int’ to ‘boost::function<int(int)>::clear_type*’ [-fpermissive]
/opt/include/boost/function/function_template.hpp:1110:14: error:   initializing argument 1 of ‘boost::function<R(T0)>::self_type& boost::function<R(T0)>::operator=(boost::function<R(T0)>::clear_type*) [with R = int, T0 = int, boost::function<R(T0)>::self_type = boost::function<int(int)>]’ [-fpermissive]
/opt/include/boost/signals2/detail/slot_template.hpp:在成员函数“void boost::signals2::slot1::init_slot_函数(const F&)[其中F=int,R=int,T1=int,SlotFunction=boost::function]:
/opt/include/boost/signals2/detail/slot_template.hpp:81:9:从“boost::signals2::slot1::slot1(常量F&)[其中F=int,R=int,T1=int,SlotFunction=boost::function]”实例化
hello world示例。cpp:13:51:从此处实例化
/opt/include/boost/signals2/detail/slot_模板。hpp:156:9:错误:从“int”到“boost::function::clear_type*”的转换无效[-fppermissive]
/opt/include/boost/function/function_template.hpp:1110:14:错误:初始化'boost::function::self_type&boost::function::operator=(boost::function::clear_type*)[with R=int,T0=int,boost::function::self_type=boost::function]'[-fpermissive]

谢谢。

在Boost 1.49版上编译似乎没有问题

在Boost 1.49版上编译似乎没有问题