Thanks very much for all your replies. I wrote
However, for maps, the second variation (declaring outside the macro) doesn't work:
map
m; ... FOREACH (map ::value_type i, m) {...} // compiles map ::value_type i; FOREACH (i, m) {...} // COMPILE ERROR
And the various replies are right on the money, and appreciated. I
thought it was something like this, but I couldn't quite figure out
what was going on.
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