Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-05-09 16:32:40


In-Reply-To: <427FB7C9.9030708_at_[hidden]>
sstrasser_at_[hidden] (Stefan Strasser) wrote (abridged):
> > 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.

"Hoisting" is fine for the purposes of this thread.

> what I meant was copy-the-value-of-end()-at-the-start-of-the-loop.
> and the proposal does that, see 3.

It says end(vec) is hoisted, but doesn't say whether vec itself is
hoisted. In "for (int i: vec )" is vec evaluated once or twice? I believe
BOOST_FOR evaluates it exactly once. The translation given in the proposal
is:

    using std::begin; // enable ADL
    using std::end; // ditto
    for( auto __begin = begin(vec),
          __end = end(vec);
         __begin != __end; ++__begin )
    {
        int i = *__begin;
        std::cout << i;
    }

which apparently evaluates vec twice. A variable __end is introduced
explicitly for end(vec), but there is no analogous variable __vec.

I guess we ought to find out for sure which it will be, and then make
BOOST_FOR do the same.

-- Dave Harris, Nottingham, UK.


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