
3 Mar
2004
3 Mar
'04
10:50 p.m.
Powell, Gary wrote:
In my plan, variables would have same scope in a function as they do now. i.e. variables local to std::accumulate are not visible in the anonymous fn. And yes its not a panacea. For instance, what about static variables in an anonymous function.
The basic question is do you bind by value or by reference? int f(std::vector<int> const & v) { int n = 0; for_each( v.begin(), v.end(), void(int const & x) { n += x; } ); return n; } function<int()> g(int n) { return int() { return n; }; }