I want a partial_sum of my elements in a vector, where each element is a pair<double, unsinged int>
. The partial_sum
should incrementally add the double values (first of each pair).
Example:
vector<pair<double, unsigned int> > temp_vec;
temp_vec.push_back(make_pair(0.5, 0));
temp_vec.push_back(make_pair(0.2, 1));
temp_vec.push_back(make_pair(0.3, 2));
partial_sum(temp_vec.begin(), temp_vec.end(), temp_vec.begin(), ???); // in place
should give me a vector containing: [(0.5, 0), (0.7, 1), (1.0, 2)]
How to implement the necessary functor to use the partial_sum function?
I was able to use my pair in a stl lower_bound search with a custom-functor, but in the case above, I don't know how to declare the binary operation.