Subject: Re: [boost] [Foreach] Proposal to simplify using Boost.Foreach with maps
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-09-14 18:12:30
Chris Purcell wrote:
> As documented in the manual ("Pitfalls"), BOOST_FOREACH is a little
> awkward to use with associative containers.
> There are a few alternatives to my solution that I have seen:
Alternatives you didn't mention:
1) Use TheContainer::value_type instead of std::pair<foo, bar>.
2) Use type deduction to avoid having to provide the type of the
elements altogether using auto or BOOST_AUTO.
I think your BOOST_FOREACH_PAIR is interesting, but maybe it could be
generalized to tuples?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk