R
roberts.noah
Richard said:Right. So according to that definition too, for_each is not a modifying
algorithm.
According to some arbitrary definition for_each may be classified as a
non-modifying algorithm (but for practical purposes it is and one of
its primary uses is to modify every element in a sequence. Running to
the standard, which picks such an arbitrary definition because
standards have to, to back the assertion that it shouldn't be used for
such purposes is silly. The standard does not require that the
operator has no side effects and so long as you are passing a mutable
iterator and can bypass item assignment it is very likely to be in you
best interests to do so.