c++ - is there a boost or stl function that implements conditional accumulation? -
I want to apply a code that adds a certain range, as long as it matches a certain condition Do not here my code is: int x [5]; Int Gateindex (Int. Valle) {Int Eye; Int xtotal = 0; For (i = 0; i break) break; Xtotal + = x [i]; } Came back; } I am using c ++ 03 function I came across the stall but I do not want to add everything. I want to add value until it is more than the input. The array is just an example and it can change a vector or whatever. You can write your own here template & lt; Typename InputIterator, TypeName ElementType, TypeName PRECIC & gt; Const Element Type Cache (if first (finally (* first)) init + = * first; (first; = last; ++ before); (first; InputIterator; return init;} He also has one that takes a binary operation, if you want to do something extra besides.