Standard C++ Library Class Reference
Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
replace_copy
Algorithm
Summary
Substitutes elements stored in a collection with new values.
Contents
Synopsis●
Description●
Complexity●
Example●
Warning●
See Also●
Synopsis
#include <algorithm>
template <class InputIterator,
class OutputIterator,
class T>
OutputIterator replace_copy (InputIterator first,
InputIterator last,
OutputIterator result,
const T& old_value,
const T& new_value);
Description
The replace_copy algorithm leaves the original sequence intact and places the revised sequence into result. The algorithm
compares elements referred to by interator i in the range [first, last) with old_value. If *i does not equal old_value, then the
replace_copy copies *i to result+(first-i). If *i==old_value, then replace_copy copies new_value to result+(first-i).
replace_copy returns result+(last-first).
Complexity
Exactly last - first comparisons between values are done.
Example
//
// replace.cpp
//