Home » C++ algorithm replace() function

C++ algorithm replace() function

by Online Tutorials Library

C++ Algorithm replace()

C++ Algorithm replace() function is used to replace all value equal to old_value by the value new_value in the range [first, last).

This function examines each element in the range and replaces it if it matches a specified value.

Syntax

Parameter

first: A forward iterator pointing to the initial position in the range from which elements are being replaced.

last: A forward iterator pointing to the final position in the range from which elements are being replaced.

old_value: The old value of the elements to be replaced.

new_value: The new value being assigned to the elements with the old value.

Return value

None

You may also like