replace_copy function template — Copies a range, replacing occurrences of one value with another value
template<typename InIter, typename OutIter, typename T>
OutIter replace_copy(InIter first, InIter last, OutIter result,
const T& old_value, const T& new_value);
The replace_copy
function
template copies values from [first
, last
) to the range that starts at result
. Values that are equal to old_value
are replaced with new_value
; other values are copied without
modification.
The return value is an iterator that points to one past the end of the result range. The source and result ranges must not overlap. Figure 13-14 illustrates the replacement process.