
Hi everyone, While reviewing phoenix V3 I encountered a bug while using mpl::for_each with a phoenix lambda, because of a name conflict (lazy phoenix for_each with mpl::for_each). The following code reproduces the bug : #include <boost/mpl/for_each.hpp> #include <boost/mpl/vector_c.hpp> #include <boost/phoenix/phoenix.hpp> #include <iostream> using boost::phoenix::arg_names::arg1; int main(int argc, const char *argv[]) { typedef boost::mpl::vector_c<int,0,1,2,3> vec; boost::mpl::for_each<vec>(std::cout << arg1); return 0; } which fails to compile with the error : In file included from main.cpp:1: dev/phoenix3/boost/phoenix/stl/algorithm/iteration.hpp: In function ‘void boost::mpl::for_each <snip irrelevant long mpl / phoenix types> main.cpp:25: instantiated from here dev/phoenix3/boost/phoenix/stl/algorithm/iteration.hpp:91: error: ‘boost::phoenix::for_each’ is not a function, /usr/include/boost/mpl/for_each.hpp:109: error: conflict with ‘template<class Sequence, class F> void boost::mpl::for_each(F, Sequence*)’ /usr/include/boost/mpl/for_each.hpp:111: error: in call to ‘for_each’ The mpl code does an unqualified call to for_each here : void for_each(F f, Sequence* = 0) { for_each<Sequence, identity<> >(f); // this is line 111 } and phoenix provides : function<impl::for_each> const for_each = impl::for_each(); The (silly) change to mpl::for_each<Sequence, identity<> >(f); obviously unbreak the build. The problem seems to be that ADL kicks in and as f (in the mpl call of for_each) is a phoenix type. I don't have a patch (yet) as I don't really know the best strategy here, nor I'm sure that my diagnostic is accurate (the ADL part that is). Mathieu- :wq