Re: [boost] FOREACH / C++ "for" proposal

In-Reply-To: <427F7635.4010303@systemhaus-gruppe.de> sstrasser@systemhaus-gruppe.de (Stefan Strasser) wrote (abridged):
you might be interested in this document from the new c++0x mailing:
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1796.html
for the naming discussion, proposed syntax is for(int i : vec) (personally I don't care if it's called BOOST_FOREACH or BOOST_FOR)
I don't mind if it is BOOST_FOR_EACH or BOOST_FOR :-)
I've questioned in the past if it is expected behaviour to do "hoisting". the proposal does.
Although it doesn't seem to say whether "vec" is hoisted, and the given translation suggests that it isn't. I imagine that is an oversight in the presentation rather than the intended semantics. Interestingly he gives an example of an adaptor which could potentially be evaluated multiple times. The proposal says: The user is required to include the standard header <iterator> in which the default version of begin()/end() is defined which seems wrong to me. #include<vector> ought to be enough to use for with std::vector, if it's a built-in facility. -- Dave Harris, Nottingham, UK.

Dave Harris schrieb:
I've questioned in the past if it is expected behaviour to do "hoisting". the proposal does.
Although it doesn't seem to say whether "vec" is hoisted, and the given translation suggests that it isn't.
maybe "hoisting" was not the right word, I only know it from a post by eric. what I meant was copy-the-value-of-end()-at-the-start-of-the-loop. and the proposal does that, see 3. -- Stefan Strasser

"Dave Harris" <brangdon@cix.compulink.co.uk> wrote in message news:memo.753692@cix.compulink.co.uk... | In-Reply-To: <427F7635.4010303@systemhaus-gruppe.de> | sstrasser@systemhaus-gruppe.de (Stefan Strasser) wrote (abridged): | > you might be interested in this document from the new c++0x mailing: | > | > http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1796.html | > | > for the naming discussion, proposed syntax is for(int i : vec) | > (personally I don't care if it's called BOOST_FOREACH or BOOST_FOR) | | I don't mind if it is BOOST_FOR_EACH or BOOST_FOR :-) | | | > I've questioned in the past if it is expected behaviour to do | > "hoisting". the proposal does. | | Although it doesn't seem to say whether "vec" is hoisted, and the given | translation suggests that it isn't. I imagine that is an oversight in the | presentation rather than the intended semantics. Interestingly he gives an | example of an adaptor which could potentially be evaluated multiple times. which example are you referring to? | The proposal says: | | The user is required to include the standard header <iterator> | in which the default version of begin()/end() is defined | | which seems wrong to me. #include<vector> ought to be enough to use for | with std::vector, if it's a built-in facility. chances are that <vector> will include <iterator> anyway. -Thorsten
participants (3)
-
brangdon@cix.compulink.co.uk
-
Stefan Strasser
-
Thorsten Ottosen