it has nothing to do with using mem_fun_ref, the following code without mem_fun_ref fails too
代码:
#include <functional>
#include <algorithm>
#include <vector>
using namespace std;
struct A {};
struct my_functor_v:public binary_function<A,int,void>
{
void operator()(A a,int t)const{}
};
struct my_functor_r:public binary_function<A,int,void>
{
void operator()(A a,int& t)const{}
};
int main()
{
vector<A> c;
c.push_back(A());
int g = 123;
for_each(c.begin(),c.end(),bind2nd(my_functor_v(),g));
// seems it's just bind2nd, have nothing to do with mem_fun_ref
// for_each(c.begin(),c.end(),bind2nd(my_functor_r(),g));
return 0;
}