Hi all
I am trying to use boost::function combined with boost::bind in order to be able to pass a callback to another function.
The callback I want to pass is a member function of the class.
The code is below
class CA{
bool IsMemberFunction( const std::string& aLine ){
return true;
}
void testUseFooPtr( boost::function< bool(const std::string& ) > aFooPtr ){
std::string aLine; // read from somewhere
if( aFooPtr( aLine ) ){
std::cout << "is fine" << std::endl;
}
}
void testFooPtr(){
std::string ciao("aa");
boost::function< bool(const std::string& ) > fooPtr( boost::bind( &CA::IsMemberFunction, this ) ); // create
// a boost function using the class memebr
testUseFooPtr( fooPtr ); // pass it as callback to another
// function
}
};
I have the following compilation error.
/usr/local/include/boost/bind/mem_fn.hpp:342: error: invalid use of non-static member function
Do you know what I am doing wrong?
Is the signature fine?
Thanks