Replace in this case is a generic c++stdlib algorithm, specifically:
void replace (ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value)
Why exactly this approach was chosen is indeed somewhat puzzling, but that’s life for you.