|
Boost Users : |
Subject: Re: [Boost-users] BOOST_FOREACH with Index
From: Daniel James (daniel_james_at_[hidden])
Date: 2009-12-14 04:28:03
2009/12/13 The Dude <thedsadude_at_[hidden]>:
>
> It's true that none of these points is really a proof. Still, I'd be
> really happy to hack my own INDEX_FOREACH, but the 500+ LOCs of
> BOOST_FOREACH left me daunted.
It's not that hard:
#define INDEX_FOREACH(index,a,b) \
for(unsigned int index = static_cast<unsigned int>(-1); \
index == static_cast<unsigned int>(-1);) \
BOOST_FOREACH(a,b) if(++index,true)
INDEX_FOREACH(i, const Foo &f, foos)
cout << "The bar of element " << i << " is " << f.bar() << endl;
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net