
14 Sep
2009
14 Sep
'09
10:12 p.m.
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?