Dec 6, 2012

[boost][mpl] lambda example typo

In Boost::mpl::lambda 's example, the code:
template< typename N1, typename N2 > struct int_plus
    : int_<( N1::value + N2::value )>
{
};

typedef lambda< int_plus<_1, int_<42> > >::type f1;
typedef bind< quote2<int_plus>, _1, int_<42> > f2;

typedef f1::apply<42>::type r1;
typedef f2::apply<42>::type r2;

BOOST_MPL_ASSERT_RELATION( r1::value, ==, 84 );
BOOST_MPL_ASSERT_RELATION( r2::value, ==, 84 );

should be:
template< typename N1, typename N2 > struct int_plus
    : int_<( N1::value + N2::value )>
{
};

typedef lambda< int_plus<_1, int_<42> > >::type f1;
typedef bind< quote2<int_plus>, _1, int_<42> > f2;

typedef f1::apply<int_<42> >::type r1;
typedef f2::apply<int_<42> >::type r2;

BOOST_MPL_ASSERT_RELATION( r1::value, ==, 84 );
BOOST_MPL_ASSERT_RELATION( r2::value, ==, 84 );

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.