Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-03-03 17:50:41


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; };
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk