Hi All,
I'm trying to connect a simple void returning function to multiple signals
of varying signature, I can see some references mentioning that it's
possible using boost::lambda::bind and boost::spirit::bind, But I keep
getting compilation errors, Is there something wrong with the following
code? Or is there a better way to do it? or is it not possible to do?
Boost version: Release 1.46.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include #include #include
#include
using namespace boost::signals2;
void func()
{
printf("Func called!");
}
main()
{
signal sig;
sig.connect( (boost::lambda::bind(func), 1) ); // Compilation error
// sig.connect( (boost::phoenix::bind(func), 1) ); // Compilation error
}
I'm getting the following compilation errors when using boost::lambda::bind:
1
2
3
4
5
/opt/include/boost/signals2/detail/slot_template.hpp: In member
function ‘void boost::signals2::slot1::init_slot_function(const F&) [with F = int, R = int, T1
= int, SlotFunction = boost::function]’:
/opt/include/boost/signals2/detail/slot_template.hpp:81:9:
instantiated from ‘boost::signals2::slot1::slot1(const F&) [with F = int, R = int, T1 = int,
SlotFunction = boost::function]’
hello-world-example.cpp:15:51: instantiated from here
/opt/include/boost/signals2/detail/slot_template.hpp:156:9: error:
invalid conversion from ‘int’ to
‘boost::function::clear_type*’ [-fpermissive]
/opt/include/boost/function/function_template.hpp:1110:14: error:
initializing argument 1 of ‘boost::function::self_type&
boost::function::operator=(boost::function::clear_type*)
[with R = int, T0 = int, boost::function::self_type =
boost::function]’ [-fpermissive]
I'm getting the following compilation errors when using
boost::phoenix::bind:
1
2
3
4
5
/opt/include/boost/function/function_template.hpp: In static member
function ‘static R
boost::detail::function::function_obj_invoker1::invoke(boost::detail::function::function_buffer&, T0) [with
FunctionObj = boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T0 = int]’:
/opt/include/boost/function/function_template.hpp:913:60:
instantiated from ‘void boost::function1::assign_to(Functor)
[with Functor =
boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T0 = int]’
/opt/include/boost/function/function_template.hpp:722:7:
instantiated from ‘boost::function1::function1(Functor,
typename boost::enable_if_c::value,
int>::type) [with Functor =
boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T0 = int, typename
boost::enable_if_c::value,
int>::type = int]’
/opt/include/boost/function/function_template.hpp:1064:16:
instantiated from ‘boost::function::function(Functor, typename
boost::enable_if_c::value,
int>::type) [with Functor =
boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T0 = int, typename
boost::enable_if_c::value,
int>::type = int]’
/opt/include/boost/function/function_template.hpp:1105:5:
instantiated from ‘typename
boost::enable_if_c::value,
boost::function&>::type
boost::function::operator=(Functor) [with Functor =
boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T0 = int, typename
boost::enable_if_c::value,
boost::function&>::type = boost::function&]’
/opt/include/boost/signals2/detail/slot_template.hpp:156:9:
instantiated from ‘void boost::signals2::slot1::init_slot_function(const F&) [with F =
boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T1 = int, SlotFunction =
boost::function]’
/opt/include/boost/signals2/detail/slot_template.hpp:81:9:
instantiated from ‘boost::signals2::slot1::slot1(const F&) [with F =
boost::phoenix::actor,
boost::fusion::vector >, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >, R = int, T1 = int, SlotFunction =
boost::function]’
../../../examples/hello-world/hello-world-example.cpp:16:51:
instantiated from here
/opt/include/boost/function/function_template.hpp:132:42: error: void
value not ignored as it ought to be
/opt/include/boost/function/function_template.hpp:133:9: error:
control reaches end of non-void function [-Werror=return-type]
Many thanks,
Sak