|
Boost Users : |
Subject: [Boost-users] doubt on boost::bind and boost::function
From: Conoscenza Silente (abruzzoforteegentile_at_[hidden])
Date: 2010-02-19 09:19:24
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net