Dear all,
I am new to Boost.Signals2, so sorry for the possibly trivial question.
My problem is that I am not able to connect a member function with
more than one argument to a signal.
My test code is the following:
--- [code] ---
#include
#include
#include <iostream>
template <typename IntT=int, typename RealT=double>
struct event_consumer
{
typedef IntT int_type;
typedef RealT real_type;
typedef boost::signals2::signal signal_type;
typedef event_consumer self_type;
void consume()
{
sig.connect(boost::bind(&self_type::process, this, _1));
sig(2,0.5);
}
void process(int_type x, real_type y)
{
std::cout << "X: " << x << " -- Y: " << y << std::endl;
}
signal_type sig;
};
int main()
{
event_consumer<> consumer;
consumer.consume();
}
--- [/code] ---
When I compile it (with g++ 4.4.2 and flags --ansi --Wall) I get this error:
--- [error] ---
$ g++ -Wall -ansi -o test_signal test_signal.cpp
In file included from .../boost/bind.hpp:22,
from test_signal.cpp:1:
.../boost/bind/bind.hpp: In instantiation of
‘boost::_bi::result_traits::*)(int, double)>’:
...//boost/bind/bind_template.hpp:15: instantiated from
‘boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >’
test_signal.cpp:15: instantiated from ‘void event_consumer::consume() [with IntT = int, RealT = double]’
test_signal.cpp:32: instantiated from here
.../boost/bind/bind.hpp:69: error: ‘void (event_consumer::*)(int, double)’ is not a class, struct, or union type
In file included from ...//function/detail/maybe_include.hpp:23,
from .../boost/function/detail/function_iterate.hpp:14,
from
.../boost/preprocessor/iteration/detail/iter/forward1.hpp:57,
from .../boost/function.hpp:64,
from .../boost/signals2/signal.hpp:18,
from .../boost/signals2.hpp:16,
from test_signal.cpp:2:
.../boost/function/function_template.hpp: In static member function
‘static void boost::detail::function::void_function_obj_invoker2::invoke(boost::detail::function::function_buffer&, T0, T1)
[with FunctionObj = boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T0 = int, T1 = double]’:
.../boost/function/function_template.hpp:913: instantiated from
‘void boost::function2::assign_to(Functor) [with Functor =
boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T0 = int, T1 = double]’
.../boost/function/function_template.hpp:722: instantiated from
‘boost::function2::function2(Functor, typename
boost::enable_if_c::type)
[with Functor = boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T0 = int, T1 = double]’
.../boost/function/function_template.hpp:1064: instantiated from
‘boost::function::function(Functor, typename
boost::enable_if_c::type)
[with Functor = boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T0 = int, T1 = double]’
.../boost/function/function_template.hpp:1105: instantiated from
‘typename boost::enable_if_c&>::type boost::function::operator=(Functor) [with Functor =
boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T0 = int, T1 = double]’
.../boost/signals2/detail/slot_template.hpp:156: instantiated from
‘void boost::signals2::slot2::init_slot_function(const F&) [with F =
boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T1 = int, T2 = double, SlotFunction =
boost::function]’
.../boost/signals2/detail/slot_template.hpp:81: instantiated from
‘boost::signals2::slot2::slot2(const F&)
[with F = boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >, R = void, T1 = int, T2 = double, SlotFunction =
boost::function]’
test_signal.cpp:15: instantiated from ‘void event_consumer::consume() [with IntT = int, RealT = double]’
test_signal.cpp:32: instantiated from here
.../boost/function/function_template.hpp:153: error: no match for call
to ‘(boost::_bi::bind_t::*)(int, double),
boost::_bi::list2*>,
boost::arg<1> > >) (int&, double&)’
--- [/error] ---
Thank you very much for the support!!!
Best,
-- Marco