I have a simple class:
class A
{
public:
void f(const int& n)
{
std::cout<<"A::f()" << n <<"\n";
}
};
and I am trying to use it as follows:
std::vector<A> vec;
A a;
vec.push_back(a);
std::for_each(vec.begin(), vec.end(), std::bind2nd(std::mem_fun_ref(&A::f), 9));
But when I compile the code, I get the following error somewhere inside the function header file:
error C2529: '_Right': link to link is illegal
If I delete the link in the f () parameter, it compiles fine. How to resolve this? I do not want to delete the link, as in my real code, copying an object is quite expensive. In addition, I do not use boost.
source
share