Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2005-05-02 19:24:35

In-Reply-To: <d55q7o$4g5$1_at_[hidden]>
SeeWebsiteForEmail_at_[hidden] (Andrei Alexandrescu (See Website
For Email)) wrote (abridged):
> > Comparing:
> >
> > BOOST_FOREACH( int i, vec )
> > cout << i;
> >
> > with:
> >
> > for (iterator i = vec.begin(); i != vec.end(); ++i)
> > cout << *i;
> >
> > the macro just doesn't seem worth it.
> In fairness, it's
> for (vector<ArbitrarilyComplexType>::iterator i = vec.begin(); i !=
> vec.end(); ++i)
> cout << *i;

No, I meant what I wrote. I usually have a suitable iterator typedef in
scope. In the worst case it is more like:

   typedef vector<ArbitrarilyComplexType> MyVec;
   for (MyVec::iterator i = vec.begin(); i != vec.end(); ++i)
       cout << *i;

where "MyVec" is some meaningful name (and is probably itself worth
putting at some larger scope - after all, where did the vec come from?).
And I see adding a typedef as clearer, transparent even, compared to the

> I think the part of the discussion that focuses on arguments for or
> against macros is misplaced.

Agreed. As I said earlier, I am not absolutely against macros; I won't
automatically vote against any proposal that uses them. I am also
objecting to BOOST_FOREACH because it is taking something simple and
making it complicated.

-- Dave Harris, Nottingham, UK.

Boost list run by bdawes at, gregod at, cpdaniel at, john at