Why are both bind
versions compiling and working without problems, even though I'm using different parameter types in each call?
- version 1 -> parameter foo vs.
- version 2 -> parameter address of foo
I'd expected version 1 to produce a compile error...
#include <iostream>
#include <functional>
using namespace std;
class Test
{
public:
bool doSomething(){ std::cout << "xxx"; return true;};
};
int main() {
Test foo;
// Version 1 using foo
std::function<bool(void)> testFct = std::bind(&Test::doSomething, foo);
// Version 2 using &foo
std::function<bool(void)> testFct2 = std::bind(&Test::doSomething, &foo);
testFct();
testFct2();
return 0;
}