[mpl] for_each and set_c: misunderstanding or bug?

A friend of mine is having problems using setc with for_each. Given the following code: struct p { template<typename T> void operator()(T) const { std::cout << typeid(T).name() << std::endl; } }; typedef mpl::vector_c<int, 1, 2> vc; typedef mpl::set< mpl::integral_c<int, 1>, mpl::integral_c<int, 2> > si; typedef mpl::set_c<int, 1, 2> sc; int main() { mpl::for_each<vc>(p()); mpl::for_each<si>(p()); mpl::for_each<sc>(p()); // line does not compile } Under gcc 4.0.1 and Boost 1.38.0, we get the following error messages for the line in question: boost/mpl/next_prior.hpp:30: error: no type named 'base' in 'struct boost::mpl::set0_c<int>' boost/mpl/eval_if.hpp:38: error: no type named 'type' in 'struct boost::mpl::next<boost::mpl::s_iter<sc, boost::mpl::set0_c<int> > >' boost/mpl/for_each.hpp:78: error: 'value' is not a member of '<declaration error>' boost/mpl/for_each.hpp:78: error: 'execute' is not a member of '<declaration error>' Is this a misunderstanding on how to use for_each and set_c on our part? Regards, -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404

AMDG Nevin ":-]" Liber wrote:
typedef mpl::vector_c<int, 1, 2> vc; typedef mpl::set< mpl::integral_c<int, 1>, mpl::integral_c<int, 2> > si; typedef mpl::set_c<int, 1, 2> sc;
int main() { mpl::for_each<vc>(p()); mpl::for_each<si>(p()); mpl::for_each<sc>(p()); // line does not compile }
It's definitely a bug since this simplified code fails with the same error. I've attached a patch against the trunk. #include <boost/mpl/set_c.hpp> #include <boost/mpl/begin.hpp> #include <boost/mpl/next.hpp> typedef boost::mpl::set_c<int, 1> sc; typedef boost::mpl::begin<sc>::type sc0; typedef boost::mpl::next<sc0>::type sc1; In Christ, Steven Watanabe
participants (2)
-
Nevin ":-]" Liber
-
Steven Watanabe