
3 Mar
2004
3 Mar
'04
9:09 p.m.
David Abrahams wrote:
I realize that I can use bind:
unsigned long n = std::accumulate( xs.begin(), xs.end(), 0UL, _1 + bind(&X::count,_2));
but that's slightly counter-intuitive since the order of the target object and its member pointer are reversed.
It sure would've been nice to be able to write _2.count, or count(_2), or _2.count(), but we can't, so we bind(). ;-) The regular syntax has its advantages, and the initial "member pointer first" surprise is a one-time adjustment.