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()
(typename _Operation::second_argument_type&) const [with _Operation =
std::mem_fun1_t<void, D, int&>]’ cannot be overloaded
Do you have any ideas about what is going on? I'll appreciate any help.