"Eric Niebler"
Eelis van der Weegen wrote:
I'm having trouble using BOOST_FOREACH to iterate over Boost.MultiIndex containers. I've attached a testcase, which fails to compile because of what looks like an ADL collision between range_iterator's end() and boost::mpl::end.
I'm using GCC 3.4.2 with foreach.hpp revision 1.22 from the sandbox. Others have reported that GCC 4.0.0 20050130 is also affected.
(I'm aware that BOOST_FOREACH isn't part of Boost yet, but it's in the review queue so I thought posting this here was appropriate.)
I can reproduce the problem with gcc 3.3.3 (cygwin), but the problem does not reproduce with Visual C++. I'm a bit at a loss here. There is really no problem with BOOST_FOREACH or with its use of Boost.Range or with Boost.MPL that I can see. It would seem to be a compiler problem. I don't know why ADL is finding a class name, and I'm not sure what a suitable work-around should be. I'll give it some thought.
Actually, I seem to recall reading about this problem (there might even be a defect report already). If anybody can refresh my memory, I'd appreciate it.
It appears to be the same problem that I ran into a few month ago... This is a combination of two problems with GCC: 1) GCC STL uses unqualified function calls to its own functions, such as end() in this particular case; 2) GCC ADL finds class names along with function names. So, if an STL algorithm is used with a sequence whose value_type has anything related to boost::mpl namespace, and this algorithm uses unqualified call, and the appropriate MPL header is included, then the problem shows up. I think GCC people are fixing number 1 (which will make the problem go away), but I don't know if they are done yet (apparently not). Regards, Arkadiy