Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-05-11 02:34:14


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)
{ ... }

HTH,

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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