E
ES Kim
Here's a simple code:
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
struct S
{
void f(int) const { }
void g(const int&) const { }
};
int main()
{
int n = 1;
vector<S> v;
for_each(v.begin(), v.end(), bind2nd(mem_fun_ref(&S::f), n));
for_each(v.begin(), v.end(), bind2nd(mem_fun_ref(&S::g), n));
}
What is the reason why the second for_each() doesn't compile?
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
struct S
{
void f(int) const { }
void g(const int&) const { }
};
int main()
{
int n = 1;
vector<S> v;
for_each(v.begin(), v.end(), bind2nd(mem_fun_ref(&S::f), n));
for_each(v.begin(), v.end(), bind2nd(mem_fun_ref(&S::g), n));
}
What is the reason why the second for_each() doesn't compile?