why did it compile errorly when i added a reference argument to a member function which is the argument to std::mem_fun()?
问题 Firstly, I had a snippet as following: struct D { int sum; D():sum(0){accum();} void incre(int arg){sum+=arg;} void accum() { int arr[]={1,2,3,4,5}; std::for_each(arr,arr+ sizeof(arr)/sizeof(int), std::bind1st(std::mem_fun(&D::incre),this)); cout << sum <<endl; } }; int main() { D(); } It compiled properly.But after my changing the member function incre to void incre(int & arg){sum+=arg;} it produced errors, like typename _Operation::result_type std::binder1st<_Operation>::operator()