I have tried the following:
typedef std::function<void(int)> callback;
struct testclass
{
void testfunc()
{
printf("test\n");
}
};
int main()
{
testclass test;
callback c = std::bind(&testclass::testfunc, &test);
c(1);
}
The output is
test
The std::bind returns a callable target like void(void), while the callback should be stored a void(int).
Why can I do this?
Aucun commentaire:
Enregistrer un commentaire