Wrap Handler in boost::protect. For lambda use boost::lambda::protect
bind(&Test2, 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'
1> with
1> [
1> Handler_t=boost::_bi::bind_t>
1> ]
1> and
1> [
1> F=boost::_bi::bind_t>
1> ]
1> and
1> [
1> R=void,
1> F=void (__cdecl *)(int),
1> L=boost::_bi::list1
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 ()(boost::_bi::type<T>,F &,A &,int)' being compiled
1> with
1> [
1> A1=boost::_bi::value>>>,
1> Handler_t=boost::_bi::bind_t>,
1> T=void,
1> F=void (__cdecl *)(boost::_bi::bind_t>),
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::operator ()(void)'
1> with
1> [
1> R=void,
1> F=void (__cdecl *)(boost::_bi::bind_t>),
1> L=boost::_bi::list1>>>>
1> ]
1> d:\projekte\test2\main.cpp(14) : see reference to class template instantiation 'boost::_bi::bind_t' being compiled
1> with
1> [
1> R=void,
1> F=void (__cdecl *)(boost::_bi::bind_t>),
1> L=boost::_bi::list1>>>>
1> ]
1> d:\projekte\test2\main.cpp(23) : see reference to function template instantiation 'void Test1>(Handler_t)' being compiled
1> with
1> [
1> R=void,
1> F=void (__cdecl *)(int),
1> L=boost::_bi::list1,
1> Handler_t=boost::_bi::bind_t>
1> ]