C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Algorithm replace_copy_if()C++ Algorithm replace_copy_if() function is used to make a copy of the range [first, last) to the range beginning at result, placing those for which pred returns true by new_value. It uses predicate pred instead of operator== to compare the elements. This function examines each element in a source range and replaces it if it satisfies a specified predicate while copying the result into a new destination range. Syntaxtemplate <class InputIterator, class OutputIterator, class UnaryPredicate, class T> OutputIterator replace_copy_if (InputIterator first, InputIterator last, OutputIterator result, UnaryPredicate pred, const T& new_value); Parameterfirst: An input iterator pointing to the initial position in the range from which elements are being replaced. last: A input iterator pointing to the final position in the range from which elements are being replaced. result: An output iterator pointing to the first element of the range where the resulting sequence is stored. pred: The unary predicate that must be satisfied if the value of an element is to be replaced. old_value: The old value of the element being replaced. new_value: The new value assigned to the element with the old value. Return valueThe replace_copy_if() function returns an output iterator pointing to the position that points to the last element written in the result sequence. |