replace_copy
Prototypetemplate <class InputIterator, class OutputIterator, class T>
OutputIterator replace_copy(InputIterator first, InputIterator last,
OutputIterator result, const T& old_value,
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. ExampleVector<int> V1;
V1.push_back(1);
V1.push_back(2);
V1.push_back(3);
V1.push_back(1);
Vector<int> V2(4);
replace_copy(V1.begin(), V1.end(), V2.begin(), 1, 99);
assert(V[0] == 99 && V[1] == 2 && V[2] == 3 && V[3] == 99);
NotesSee also |