Topic: Can std::for_each modify a sequence?
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1998/12/10 Raw View
alanstokes@my-dejanews.com wrote:
> Is it legitimate to pass to std::for_each a function (or function object)
> which will modify its parameter - so that each item in the sequence gets
> modified?
Yes, perfectly legitimate
> I can't see anything one way or the other in the standard. for_each is
> described under the heading "Non-modifying sequence operations", but I don't
> think this term is anywhere defined [mutter grumble stupid Acrobat doesn't
> seem to be able to find anything with a hyphen in it] - and are headings
> normative anyway? And the description of for_each in 25.1.1 doesn't leave me
> any the wiser.
It's there because moving things in a different section is error prone,
or
because no one cared to move it.
> The Dinkumware reference, which I have a great deal of respect for, states
> that the function must not modify the element, but I'd prefer chapter and
> verse on this.
We got rid of this non sens. Perhaps the reference you cite is out of
date.
--
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: alanstokes@my-dejanews.com
Date: 1998/12/09 Raw View
Is it legitimate to pass to std::for_each a function (or function object)
which will modify its parameter - so that each item in the sequence gets
modified?
I can't see anything one way or the other in the standard. for_each is
described under the heading "Non-modifying sequence operations", but I don't
think this term is anywhere defined [mutter grumble stupid Acrobat doesn't
seem to be able to find anything with a hyphen in it] - and are headings
normative anyway? And the description of for_each in 25.1.1 doesn't leave me
any the wiser.
The Dinkumware reference, which I have a great deal of respect for, states
that the function must not modify the element, but I'd prefer chapter and
verse on this.
--
- Alan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]