Boost logo

Boost :

From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2004-05-23 04:57:03


[Jaakko Jarvi]
> for_each is the only one that takes a 'free-form' function
> object.

Yes, as I said, it is "special".

> If side effects are allowed, I don't understand why for_each
> is classified as a non-modifying sequence. It sure can modify
> the elements of the sequence. What is (philosophically)
> different in the way that, say, std::replace, modifies the
> elements of the sequence?

Because for_each() does not do the modifying, the /functor/ does the
modifying. Contrast replace(), which does the modifying itself.

> Do you know what Bjarne is referring to with the 'recent
> standards resolution'?

I have E-mailed him asking for a clarification.

> The sgi STL documentation (predecessor of what is currently
> in the standard)

... is wrong wrt the final Standard.

> This must be the initial reason why for_each is in the
> category of non-modifying sequences.

It may have been that this was the intent pre-Standardization.

> A DR would be in place: either explicitly mention that
> side-effects (of the sort that modify the values in the
> sequence) are not allowed, or move for_each to mutating algs.
> Volunteer to raise that and provide wording?

I don't believe that a DR is necessary given the phrasing in TC++PL, which
is reasonably authoritative (though lacking Standard force).

Stephan T. Lavavej


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk