Eric Niebler writes:
Dave Steffen wrote:
If anyone's interested: I'm playing with the idea of extending FOREACH in a way so that, instead of having a pair<>, you've got two separate variables for key and value. Maybe something like:
map<int,int> m; ... FOREACH_PAIR(int key, int value, m) { ... }
I'm having a very moderate amount of success. Anyone else playing with this sort of thing?
Can't find the reference now, but someone suggested using tie() from the tuples library for this:
int key, int value; BOOST_FOREACH(boost::tie(key, value), m) { ... }
Ah, yes, this is the sort of thing I was after. I'll look into it. Every loop I've written for the past two weeks has turned out to be an iteration over a map of some sort; they are, now, all FOREACH loops. Being the lazy sort of programmer I am, I'm now looking for ways to customize FOREACH to make iteration over maps easier. Thanks very much! ---------------------------------------------------------------------- Dave Steffen, Ph.D. "The only justification for our concepts and Software Engineer IV systems of concepts is that they serve to Numerica Corporation represent the complex of our experiences; ph (970) 419-8343 x27 beyond this they have no legitimacy." fax (970) 223-6797 -- Albert Einstein dgsteffen@numerica.us