22 Sep
2009
22 Sep
'09
2:11 p.m.
If a given class defines operator + and there is a vector of instances of that class: how I can use std::accumulate to count sum against this vector for the elements that satisfy certain conditions? class A { public: A(useinsum) : _useinsum(useinsum) {}; bool useinsum() {return _useinsum;} int operator + (int a) {return _i + a;} private bool _useinsum; int _i; } std::vector<A> lst; will that work? std::accumulate(lst.begin(), lst.end(), 0, boost::lambda::bind(&A::useinsum, boost::lambda::_1) == false)