
Hi, I'm stuck at exercise 3-6 of the book. I have to write twice (see below) as a lambda expression. I don't understand why the same transformation that works for quasi fails for twice. Any help, please? #include <boost/type_traits/add_pointer.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/mpl/assert.hpp> #include <boost/mpl/plus.hpp> #include <boost/mpl/int.hpp> #include <boost/mpl/placeholders.hpp> #include <boost/mpl/apply.hpp> #include <boost/mpl/lambda.hpp> #include <boost/mpl/equal_to.hpp> using namespace boost; using namespace boost::mpl; using namespace boost::mpl::placeholders; template <class F, class A> struct twice : apply<F, typename apply<F, A>::type > {}; BOOST_MPL_ASSERT(( is_same<twice<add_pointer<_1>,int>::type, int**> )); template <class F, class A> struct quasi : plus<F, typename plus<F, A>::type > {}; BOOST_MPL_ASSERT(( equal_to<quasi<int_<2>,int_<3> >, int_<7> > )); template <class F, class A> struct quasi2 : apply<plus<_1, plus<_1,_2> >, F, A >::type {}; BOOST_MPL_ASSERT(( equal_to<quasi2<int_<2>,int_<3> >, int_<7> > )); template <class F, class A> struct twice2 : apply<apply<_1, apply<_1,_2> >, F, A >::type {}; BOOST_MPL_ASSERT(( is_same<twice2<add_pointer<_1>,int>::type, int**> )); - Bruno