Please quote enough material for your post to stand alone. Here is again the
quote from the standard:
[25.2.4/3-5]
template<class InputIterator, class OutputIterator, class T>
OutputIterator
replace_copy(InputIterator first, InputIterator last,
OutputIterator result, const T& old_value, const T& new_value);
template<class Iterator, class OutputIterator, class Predicate, class T>
OutputIterator
replace_copy_if(Iterator first, Iterator last,
OutputIterator result, Predicate pred, const T& new_value);
4 Requires: Type T is Assignable (23.1) (and, for replace_copy(),
EqualityComparable (20.1.1). The ranges [first, last) and [result, result +
(last - first)) shall not overlap.
5 Effects: Assigns to every iterator i in the range [result, result +
(last - first)) either new_value or *(first + (i - result)) depending on
whether the following corresponding conditions hold: *(first + (i -
result)) == old_value, pred(*(first + (i - result))) != false.
Fraser Ross said:
The order of invocation and doing a stable copy are not the same thing.
I would expect the intention is to do a stable copy. It should be
stated as it is with the remove algorithms. unique_copy is probably
another that should state a stable copy is done.
The standard does not talk about "order of invocation" at all. It sets which
OutputIterator gets assigned which value: the OutputIterator result+n,
i.e., n slots past result is assigned the value from the InputIterator
from+n or the value new_value depending on the result of the test. This
only specifies the order in which the items will occur in the output
sequence but it does not specify the order in which the necessary
assignments are carried out. In other words, this spells out that the copy
is stable but does not specify the order of any invocations. For example,
if both iterators are bidirectional, the process could go backwards, but
the resulting output sequence is still uniquely determined by the
positional requirements set out in the Effects section.
However, maybe, I misunderstand what you mean.
Best
Kai-Uwe Bux