Next : , Previous : Transform, Top : Table of  Contents


Replace

replace (ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value) Function
replace_if (ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value); Function

template 
void replace(ForwardIterator first, ForwardIterator last,
             const T& old_value, const T& new_value);

template 
void replace_if(ForwardIterator first, ForwardIterator last,
                Predicate pred, const T& new_value);

replace substitutes elements referred by the iterator i in the range [first, last) with new_value, when the following corresponding conditions hold: *i == old_value, pred(*i) == true. Exactly last - first applications of the corresponding predicate are done.

 

OutputIterator replace_copy (InputIterator first, InputIterator last, OutputIterator result, const T& old_value, const T& new_value) Function
OutputIterator replace_copy_if (Iterator first, Iterator last, OutputIterator result, Predicate pred, const T& new_value) Function

template 




OutputIterator replace_copy(InputIterator first, InputIterator last,
                            OutputIterator result,
                            const T& old_value, const T& new_value);

template 




OutputIterator replace_copy_if(Iterator first, Iterator last,
                               OutputIterator result, Predicate pred,
                               const T& new_value);

replace_copy assigns to every iterator i in the range [result, result + (last - first)) either new_value or *(first + (i - result)) depending on whether the following corresponding conditions hold: *(first + (i - result)) == old_value, pred(*(first + (i - result))) == true. replace_copy returns result + (last - first). Exactly last - first applications of the corresponding predicate are done.