Link to home
Start Free TrialLog in
Avatar of Rothbard
RothbardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Question about BOOST_FOREACH

Suppose I have a std::vector of double called myVec, and a std::map of type <int, double> called myMap. Why is it that the following works

BOOST_FOREACH(double x, myVec) x = 10.0;

Open in new window

and the following gives an error
BOOST_FOREACH(pair<int,double> y, myMap) 
cout << y.first << "\t" << y.second << endl;

Open in new window

so that I need to use

pair<int,double> y;
BOOST_FOREACH(y, myMap) cout << y.first << "\t" << y.second << endl;

Open in new window

instead?
ASKER CERTIFIED SOLUTION
Avatar of kuroji
kuroji
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial