Re: [Boost-users] boost.bind: nested bind fails

Wrap Handler in boost::protect. For lambda use boost::lambda::protect
bind(&Test2<Handler_t>, boost::protect(Handler))();
Sorry, but this does not work. 1>d:\projekte\libs\boost_1_35\build\x86\include\boost-1_35\boost\bind.hpp(232) : error C2664: 'void (Handler_t)' : cannot convert parameter 1 from 'boost::_bi::protected_bind_t<F>' to 'boost::_bi::bind_t<R,F,L>' 1> with 1> [ 1> Handler_t=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>> 1> ] 1> and 1> [ 1> F=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>> 1> ] 1> and 1> [ 1> R=void, 1> F=void (__cdecl *)(int), 1> L=boost::_bi::list1<boost::_bi::value<int>> 1> ] 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1> d:\projekte\libs\boost_1_35\build\x86\include\boost-1_35\boost\bind\bind_template.hpp(20) : see reference to function template instantiation 'void boost::_bi::list1<A1>::operator ()<void(__cdecl *)(Handler_t),boost::_bi::list0>(boost::_bi::type<T>,F &,A &,int)' being compiled 1> with 1> [ 1> A1=boost::_bi::value<boost::_bi::protected_bind_t<boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>>>, 1> Handler_t=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>, 1> T=void, 1> F=void (__cdecl *)(boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>), 1> A=boost::_bi::list0 1> ] 1> d:\projekte\libs\boost_1_35\build\x86\include\boost-1_35\boost\bind\bind_template.hpp(18) : while compiling class template member function 'void boost::_bi::bind_t<R,F,L>::operator ()(void)' 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>), 1> L=boost::_bi::list1<boost::_bi::value<boost::_bi::protected_bind_t<boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>>>> 1> ] 1> d:\projekte\test2\main.cpp(14) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>), 1> L=boost::_bi::list1<boost::_bi::value<boost::_bi::protected_bind_t<boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>>>>> 1> ] 1> d:\projekte\test2\main.cpp(23) : see reference to function template instantiation 'void Test1<boost::_bi::bind_t<R,F,L>>(Handler_t)' being compiled 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(int), 1> L=boost::_bi::list1<boost::_bi::value<int>>, 1> Handler_t=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::value<int>>> 1> ]

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 14 May 2008 14:58 pm, gfsdjkgf@Safe-mail.net wrote:
Wrap Handler in boost::protect. For lambda use boost::lambda::protect
bind(&Test2<Handler_t>, boost::protect(Handler))();
Sorry, but this does not work.
It looks like you need to change the template parameter on Test2, I guess to something like Test2<boost::_bi::protected_bind_t<Handler_t> > Of course, in your minimal example code the second bind isn't really needed at all, but I guess your real use case is different.
1>d:\projekte\libs\boost_1_35\build\x86\include\boost-1_35\boost\bind.hpp(2 32) : error C2664: 'void (Handler_t)' : cannot convert parameter 1 from 'boost::_bi::protected_bind_t<F>' to 'boost::_bi::bind_t<R,F,L>' 1>
- -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIKzj95vihyNWuA4URAk2nAKCtMTZoRYieYFSlm+OM6UGmQfCjBwCfayxf LHC0/jxPWVA1nQ76dv2wl5A= =vjT5 -----END PGP SIGNATURE-----

AMDG gfsdjkgf@Safe-mail.net wrote:
Wrap Handler in boost::protect. For lambda use boost::lambda::protect
bind(&Test2<Handler_t>, boost::protect(Handler))();
Sorry, but this does not work.
I see. The explicit template parameter needs to be updated too. #include <boost/bind.hpp> #include <boost/bind/protect.hpp> using boost::bind; //#include <boost/lambda/bind.hpp> //using boost::lambda; template<class Handler_t>void Test2(Handler_t Handler) { } template<class Handler_t>void Test1Impl(Handler_t Handler) { bind(&Test2<Handler_t>, Handler)(); } template<class Handler_t>void Test1(Handler_t Handler) { Test1Impl(boost::protect(Handler)); } void TestFunc(int i) { } int main() { Test1(bind(TestFunc,0)); } In Christ, Steven Watanabe
participants (3)
-
Frank Mori Hess
-
gfsdjkgf@Safe-mail.net
-
Steven Watanabe