My confuse is like this code:
#include "stdafx.h"
#include <boost/bind.hpp>
using namespace std;
void fool(std::string s)
{
std::cout<<s<<endl;
}
void fool2()
{
std::cout<<"test2 called\n"<<endl;
}
void fool3(std::string s1,std::string s2)
{
std::cout<<"test3 called\n"<<endl;
}
typedef boost::function<void(std::string)> myHandler;
void mywait(myHandler handler)
{
handler("hello my wait");
}
int main()
{
mywait(boost::bind(fool,_1)); //it works fine as expected.
mywait(boost::bind(fool2)); //how it works? fool2 doesnot match the signature of "boost::function<void(std::string)>"
//mywait(boost::bind(fool3,_1,_2)); //if fool2 works fine, why this not work?
return 0;
}
the follow link is the same question.
i just read the article: [How the Boost Bind Library Can Improve Your C++ Programs] and the boost doc about bind
those just say it works,but i don't know why. i still confused.
sorry about my poor English.wish i explained clearly yet.