Why doesn't ::boost::tie work with BOOST_FOREACH?
问题 I want to use BOOST_FOREACH to iterate over a boost::ptr_map , and came across this neat-looking solution. I would prefer using this for better readability, as against the other solutions given. I wrote the following code: boost::ptr_map<int, std::string> int2strMap; int x = 1; int2strMap.insert(x, new std::string("one")); int one; std::string* two; BOOST_FOREACH(::boost::tie(one, two), int2strMap) { std::cout << one << two << std::endl; } However, this fails to compile, and gives me the