absl::c_replace_copy_if

Container-based version of the <algorithm> std::replace_copy_if() function to replace a container's elements of some value with a new value based on some condition, and return the results within an iterator.

Synopsis

Declared in <absl/algorithm/container.h>

template<
    typename C,
    typename OutputIterator,
    typename Pred,
    typename T>
constexpr
OutputIterator
c_replace_copy_if(
    C const& c,
    OutputIterator result,
    Pred&& pred,
    T const& new_value);

Return Value

An iterator to the end of the copied range in the output.

Parameters

NameDescription
cThe container whose elements to copy.
resultThe output iterator receiving the copied elements.
predThe predicate selecting which elements to replace.
new_valueThe value to substitute for matching elements.