|
Boost Users : |
From: Eric Niebler (eric_at_[hidden])
Date: 2006-09-18 14:37:29
Rob Caldecott wrote:
> OK, I know BOOST_FOREACH isn't part of the official (1.33.1) build yet, but
> hopefully some people here are using this excellent algorithm and can help
> me out... (note that I am using MS Visual Studio 2005):
>
> How can I use BOOST_FOREACH to iterate through a map? For example, the
> following won't build:
>
> std::map<int, int> m;
> BOOST_FOREACH(std::pair<int, int> p, m)
> {
> }
>
> I get the following error:
>
> warning C4002: too many actual parameters for macro 'BOOST_FOREACH'
>
This is covered in the docs:
http://tinyurl.com/l72gp
Your solutions (pre-declare the loop variable or use a typedef) are the
way to go.
-- 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