C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Algorithm replace_if()C++ Algorithm replace_if() function is used to assign new_value to all the elements in the range [first, last) for which pred predicate returns true. This function examines each element in a range and replaces it if it satisfies a specified predicate. Syntaxtemplate <class ForwardIterator, class UnaryPredicate, class T> void replace_if (ForwardIterator first, ForwardIterator last, UnaryPredicate pred, const T& new_value ); Parameterfirst: 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. pred: The unary predicate function that must be satisfied is the value of the element is to be replaced. new_value: The new value assigned to the elements whose old value satisfies the predicate. Return valueNone |