Entendiendo std :: function y std :: bind
Estaba jugando con std :: function y std :: bind y noté algo poco intuitivo y me gustaría entenderlo mejor.
Por ejemplo:
void fun()
{
}
void hun(std::string)
{
}
int main()
{
function<void(int)> g = &fun; //This fails as it should in my understanding.
function<void(int)> f = std::bind(fun); //This works for reasons unknown to me
function<void(int, std::string)> h = std::bind(hun); //this doesn't work
return 0;
}
¿Cómo es posible unir unfunction<void(int)>
a una función que esvacío(). Entonces podría llamar a f (1) y divertirme (). Me gustaría entender cómo se hace esto. Al entrar en la implementación de Microsoft Visual Studio 2012 de esto, me perdí en un mar de macros ilegibles. Por eso hago esta pregunta aquí.