josgood
asked on
Boost::Bind cannot convert from 'boost::_bi::bind_t<R,F,L>'
I need some boost::bind help. I'm simply out of my depth here.
#include <boost/bind.hpp>
typedef void (*MY_CALLBACK)(unsigned short);
class TestClass {
TestClass();
void OnEvent(unsigned short);
};
TestClass::TestClass() {
MY_CALLBACK cb = boost::bind(&TestClass::On Event,this ,_1);
}
void TestClass::OnEvent(unsigne d short) { }
void main() {
}
generates this error
error C2440: 'initializing' : cannot convert from 'boost::_bi::bind_t<R,F,L> ' to 'MY_CALLBACK'
1> with
1> [
1> R=void,
1> F=boost::_mfi::mf1<void,Te stClass,un signed short>,
1> L=boost::_bi::list2<boost: :_bi::valu e<TestClas s *>,boost::arg<1>>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
#include <boost/bind.hpp>
typedef void (*MY_CALLBACK)(unsigned short);
class TestClass {
TestClass();
void OnEvent(unsigned short);
};
TestClass::TestClass() {
MY_CALLBACK cb = boost::bind(&TestClass::On
}
void TestClass::OnEvent(unsigne
void main() {
}
generates this error
error C2440: 'initializing' : cannot convert from 'boost::_bi::bind_t<R,F,L>
1> with
1> [
1> R=void,
1> F=boost::_mfi::mf1<void,Te
1> L=boost::_bi::list2<boost:
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
jkr,
The cast changes the error...
MY_CALLBACK cb = (MY_CALLBACK)boost::bind(& TestClass: :OnEvent,t his,_1);
error C2440: 'type cast' : cannot convert from 'boost::_bi::bind_t<R,F,L> ' to 'MY_CALLBACK'
1> with
1> [
1> R=void,
1> F=boost::_mfi::mf1<void,Te stClass,un signed short>,
1> L=boost::_bi::list2<boost: :_bi::valu e<TestClas s *>,boost::arg<1>>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
The cast changes the error...
MY_CALLBACK cb = (MY_CALLBACK)boost::bind(&
error C2440: 'type cast' : cannot convert from 'boost::_bi::bind_t<R,F,L>
1> with
1> [
1> R=void,
1> F=boost::_mfi::mf1<void,Te
1> L=boost::_bi::list2<boost:
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry. I meant for your answer to be the solution and somehow messed it up.
ASKER
I meant for EvilRx's answer to be the solution.
ASKER
Thank you. I have some other thinking to do, but you have answered the question.
I appreciate your help.
Joe
I appreciate your help.
Joe
TestClass::TestClass() {
MY_CALLBACK cb = (MY_CALLBACK)boost::bind(&
}
?