#include <algorithm> template< class ForwardIterator, class T > void replace( ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value );
Replaces all elements with value old_value
to value new_value
in the range defined by [first, last)
.
first
, last
- the range of the elements to be processed
old_value
- value of the elements to be replaced
new_value
- value to be replaced with
(none)
template<class ForwardIterator, class T> void replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value) { for (; first != last; ++first) { if (*first == old_value) { *first = new_value; } } }
linear in the distance between first
and last