Boost logo

Boost Users :

Subject: [Boost-users] std::accumulate with condition?
From: Archie14 (admin_at_[hidden])
Date: 2009-09-22 10:11:52


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)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net