replace_copy_if
Prototypetemplate <class InputIterator, class OutputIterator, class Predicate, class T> OutputIterator replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value) Description
DefinitionDefined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h. Requirements on types
Preconditions
ComplexityLinear. ExampleCopy elements from one Vector to another, replacing all negative numbers with Vector<int> V1; V1.push_back(1); V1.push_back(-1); V1.push_back(-5); V1.push_back(2); Vector<int> V2(4); replace_copy_if(V1.begin(), V1.end(), V2.begin(), bind2nd(less<int>(), 0), 0); assert(V[0] == 1 && V[1] == 0 && V[2] == 0 && V[3] == 2); NotesSee also |