replace_if

template<class FwdIt, class Pred, class T>
    void replace_if(FwdIt first, FwdIt last,
        Pred pr, const T& val);

The template function executes the statement:

if (pr(*(first + N)))
    *(first + N) = val;

once for each N in the range [0, last - first).

See the related sample program.