Why is this code resulting in a compiler error?
#include <iostream>
#include <algorithm>
using namespace std;
class X
{
public:
void Print(int x)
{
cout << x << endl;
}
};
int main()
{
X x;
mem_fun_ref<void, X, int>(&X::Print) p;
};
Error
main.cpp:18: error: expected ; before p
mem_fun_refis a function template, so it does not name a type.mem_fun_ref<void, X, int>(&X::Print)is a function call that returns a value, so it makes no sense that there is apfollowing it.The return value of that function call is a
mem_fun1_ref_t<void, X, int>, in case you were looking for that.