Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-05-09 13:09:18


Eric Niebler <eric <at> boost-consulting.com> writes:

>
>
> Stefan Strasser wrote:
> > 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've questioned in the past if it is expected behaviour to do
> > "hoisting". the proposal does.
> >
> > "4 Making a custom type work with the for loop" may also be
> > interesting to make the BOOST_FOREACH extension mechanism similar.
> >
>
> This essentially *is* the BOOST_FOREACH extension mechanism, or what it
> would be if we had auto and decltype today.
>
> I'm glad to see foreach moving ahead in the committee. Obviously, I'm of
> the opinion that C++ needs this.
>
> This proposal is a good start, but it seems to take quite a bit for
> granted. It depends on the auto function(...) -> decltype(...) syntax.
> It depends on rvalue references. It assumes that the Boost.Range begin()
> and end() functions exist in std namespace (and I'm not aware of a
> proposal to add those). Perhaps the proposal should discuss alternate
> designs should certain features not make it into the language.

yeah, that is always a concern. I do think it is likely that the
machinery I use in the proposal will be avaiable in C++0x
(please not this is my personal opinion)

> It also relies on ADL of the begin() and end() functions, even though we
> decided, after a very lengthy discussion on Boost.Users, that this isn't
> the way to go, IIRC.

it was decided that intrusive/automatic ADL from a qualified call to
boost::begin should *not* do ADL.

that is different from what I propose in the proposal. In Lillehammer I started
out with not using ADL, but it just didn't feel right; I gave it a lot of
thought before I changed it and tried to compile some examples where ADL must
find functions defined after the template, but before the instantiation; it
worked as I hoped, so I don't see any good reason for not letting us use ADL.

> Also it requires users to #include <iterator> in order to use the new
> looping construct. There's precedent for that, though, because users
> must #include <typeinfo> to use typeid. I can't decide how I feel about
> that. Perhaps there's another way.

I spoke with several implementers and they all said that we need to include
some special header...otherwise it is very problematic to let the compiler and
standard library work together.

> It surprises me a bit that Thorsten makes no mention of BOOST_FOREACH in
> this proposal, though. Seems relevant, if only to establish interest and
> existing practice.

yeah, sorry about that. I think I actually had some of your stuff in there, but
people where confused about what I was actually trying to propose...so I cut
some stuff away.

Anyway, I should mention your work...and I will when I get a change to present
it in Quebec or later.

best regards

-Thorsten
 


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