Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

replace_if


Algorithm

Summary

Substitutes elements in a collection with new values.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

None

Synopsis

#include <algorithm>
template <class ForwardIterator,
          class Predicate,
          class T>
void replace_if (ForwardIterator first,
                 ForwardIterator last,
                 Predicate pred
                 const T& new_value);

Description

The replace_if algorithm replaces element referred to by iterator i in the range [first, last) with new_value when the following condition holds: pred(*i) == true.

Complexity

Exactly last - first applications of the predicate are done.

Example

Program Output

Warnings

If your compiler does not support default template parameters, then you always need to supply the Allocator template argument. For instance, you need to write:

vector<int, allocator<int> >

instead of:

vector<int>

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

replace, replace_copy, replace_copy_if



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998