BOOST_FOREACHはつかったことがないんだけども、
ループ変数の定義の中にコンマが含まれていると、マクロの引数の区切りのコンマと間違えられてエラーになるということがあるらしい。
Pitfallsにあるtypedefする方法と外部で定義する方法以外にこんなのはどうか。
#include <map>
#include <boost/foreach.hpp>
#include <iostream>
int
main()
{
std::map<int, int> m;
m[1]=1;
m[2]=4;
m[3]=9;
#if 0
BOOST_FOREACH(std::map<int, int>::value_type const& iter, m)
{
std::cout<<iter.second<<std::endl;
}
#endif
#define THRU(X,...) X,__VA_ARGS__
BOOST_FOREACH(THRU(std::map<int, int>::value_type const& iter), m)
{
std::cout<<iter.second<<std::endl;
}
BOOST_FOREACH(auto iter, m)
{
std::cout<<iter.second<<std::endl;
}
return 0;
}













