Hi,
I'm *partially* answering to myself.
On Thu, 03 Mar 2005 22:54:56 -0200, Bruno MartÃnez Aguerre
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
#include #include
#include #include #include #include #include #include using namespace boost; using namespace boost::mpl; using namespace boost::mpl::placeholders;
template
struct twice : apply ::type > {}; BOOST_MPL_ASSERT(( is_same
,int>::type, int**> )); template
struct quasi : plus ::type > {}; BOOST_MPL_ASSERT(( equal_to
,int_<3> >, int_<7> > ));
This works because quasi inherits from plus that inherits from int_.
template
struct quasi2 : apply >, F, A >::type {};
Here ::type makes quasi2 inherit from int_, too, ...
BOOST_MPL_ASSERT(( equal_to
,int_<3> >, int_<7> > ));
... so this works again.
template
struct twice2 : apply >, F, A >::type {}; BOOST_MPL_ASSERT(( is_same
,int>::type, int**> ));
This has a number of bugs from copying quasi2. Something that works would
be:
template