|
Boost : |
From: richielee616_at_[hidden]
Date: 2001-11-26 08:02:53
I define two signals, and I want connect one to the other:
signal2<void, int, int> sig1,sig2;
sig1.connect(sig2);
my compiler ( MSVC6.0 SP5 ) refuse to compile:
d:\cpplibs\include\boost\function\function_base.hpp(195) : error
C2558: class 'boost::signal2<void,int,int,struct
boost::return_last_value<void> >' : no copy constructor available
d:\cpplibs\include\boost\function\function_base.hpp(178) : while
compiling class-template member function 'union
boost::detail::function::any_pointer __cdecl
boost::detail::function::functor_manager<class
boost::signal2<void,int,int,struct boost::return_last_value<void>
>,int>::manager(union boost::detail::function::any_pointer,enum
boost::detail::function::functor_manager_operation_type,struct
boost::detail::function::function_obj_tag)'
so I add an function slot_sig to do so:
void slot_sig( int x, int y, const signal2<void,int,int> &sig )
{
sig( x, y );
}
signal2<void, int, int> sig1,sig2;
sig1.connect(bind(slot_sig,_1,_2,sig2));
there is still an error:
d:\projects\temp\boo_9.cpp(31) : error C2664: 'class
boost::_bi::bind_t<void,void (__cdecl*)(int,int,class
boost::signal2<void,int,int,struct boost::return_last_value<void> >
&),class boost::_bi::list3<class boost::_bi::arg<1>,class
boost::_bi::arg<2>,class boost::_bi::value<class
boost::signal2<void,int,int,struct boost::return_last_value<void> > >
> > __cdecl boost::bind(void (__cdecl *)(int,int,class
boost::signal2<void,int,int,struct boost::return_last_value<void> >
&),class boost::_bi::arg<1>,class boost::_bi::arg<2>,class
boost::signal2<void,int,int,struct boost::return_last_value<void>
>)' : cannot convert parameter 4 from 'class
boost::signal2<void,int,int,struct boost::return_last_value<void> >'
to 'class boost::signal2<void,int,int,struct
boost::return_last_value<void> >'No copy constructor available for
class 'boost::signal2<void,int,int,struct
boost::return_last_value<void> >'
at last, I change the third parameter from type 'const
signal2<void,int,int>&' to 'const siganl2<void,int,int> *'.
void slot_sig( int x, int y, const signal2<void,int,int> *sig )
{
(*sig)( x, y );
}
signal2<void, int, int> sig1,sig2;
sig1.connect(bind(slot_sig,_1,_2,&sig2));
It passed at last!
My question is: Did I make mistakes? What is the right way to connect
a signal to anther one?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk