
"Joel de Guzman" <joel@boost-consulting.com> wrote in message news:4046A2AE.8020408@boost-consulting.com...
Jonathan Turkanis wrote:
How about:
unsigned long n = std::accumulate( xs.begin(), xs.end(), 0UL, auto(long lhs, const auto& rhs) // inline fn
with no
name. { return lhs + rhs.count; } );
I would prefer also eliding the argument types:
unsigned long n = std::accumulate( xs.begin(), xs.end(), 0UL, lambda(lhs, rhs) { return lhs + rhs.count; } );
Most of the time, you also do not know the type of the arguments before hand.
That's why I used 'auto'. (Maybe I should have used it for the first argument position, too.) Isn't it useful to have a way to specify whether the argument is to be passed by value, reference, const reference, etc. ? Jonathan