From Cppreference, I found it noted that
Pointers to data members are Callable, even though no function calls take place.
However, when I test following code
#include <iostream>
#include <functional>
using namespace std;
class CTest
{
public:
CTest() : n(0) {}
~CTest() {}
public:
int n;
};
int main() {
CTest o;
auto f = std::bind(&CTest::n, o);
f(1) = 2;
cout << f() << endl;
return 0;
}
I found that I can call f
with any arguments, not limited by count or type.
So, why can I insert almost any thing into f(...)
? Is the syntax like
template<class... Args>
int f(Args&&... args) {
return *pointer_to_data;
}