23 Jul
2007
23 Jul
'07
11:50 p.m.
David Abrahams wrote: >>>> It might be easier to just make it work by adding the appropriate A >>>> const& overloads to lambda_functor, as we did with boost::bind. ... > Well, then, I would go for that. But we'd have to get someone who > knows BLL to do the work ;-) Yeah. Patch: Index: lambda_functors.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/lambda/detail/lambda_functors.hpp,v retrieving revision 1.8 diff -u -r1.8 lambda_functors.hpp --- lambda_functors.hpp 6 Jul 2006 13:47:26 -0000 1.8 +++ lambda_functors.hpp 23 Jul 2007 23:44:39 -0000 @@ -148,6 +148,14 @@ >(a, cnull_type(), cnull_type(), cnull_type()); } + template+ typename inherited::template sig >::type + operator()(A const& a) const { + return inherited::template call< + typename inherited::template sig >::type + >(a, cnull_type(), cnull_type(), cnull_type()); + } + template typename inherited::template sig >::type operator()(A& a, B& b) const { @@ -156,6 +164,30 @@ >(a, b, cnull_type(), cnull_type()); } + template + typename inherited::template sig >::type + operator()(A const& a, B& b) const { + return inherited::template call< + typename inherited::template sig >::type + >(a, b, cnull_type(), cnull_type()); + } + + template + typename inherited::template sig >::type + operator()(A& a, B const& b) const { + return inherited::template call< + typename inherited::template sig >::type + >(a, b, cnull_type(), cnull_type()); + } + + template + typename inherited::template sig >::type + operator()(A const& a, B const& b) const { + return inherited::template call< + typename inherited::template sig >::type + >(a, b, cnull_type(), cnull_type()); + } + template typename inherited::template sig >::type operator()(A& a, B& b, C& c) const @@ -165,6 +197,15 @@ >(a, b, c, cnull_type()); } + template + typename inherited::template sig >::type + operator()(A const& a, B const& b, C const& c) const + { + return inherited::template call< + typename inherited::template sig >::type + >(a, b, c, cnull_type()); + } + // for internal calls with env template typename inherited::template sig >::type Test: #include #include int main() { using namespace boost::lambda; int x = 0; int const y = 1; int const z = 2; BOOST_TEST( _1( x ) == 0 ); BOOST_TEST( _1( y ) == 1 ); BOOST_TEST( _1( 2 ) == 2 ); BOOST_TEST( _2( x, x ) == 0 ); BOOST_TEST( _2( x, y ) == 1 ); BOOST_TEST( _2( x, 2 ) == 2 ); BOOST_TEST( _2( 4, x ) == 0 ); BOOST_TEST( _2( 4, y ) == 1 ); BOOST_TEST( _2( 4, 2 ) == 2 ); (_1 = _2)( x, y ); BOOST_TEST( x == y ); (_1 = _2)( x, 3 ); BOOST_TEST( x == 3 ); (_2 = _1)( z, x ); BOOST_TEST( x == z ); (_2 = _1)( 4, x ); BOOST_TEST( x == 4 ); BOOST_TEST( _3( x, x, x ) == x ); BOOST_TEST( _3( x, x, y ) == y ); BOOST_TEST( _3( x, x, 2 ) == 2 ); BOOST_TEST( _3( x, 5, x ) == x ); BOOST_TEST( _3( x, 5, y ) == y ); BOOST_TEST( _3( x, 5, 2 ) == 2 ); BOOST_TEST( _3( 9, 5, x ) == x ); BOOST_TEST( _3( 9, 5, y ) == y ); BOOST_TEST( _3( 9, 5, 2 ) == 2 ); return boost::report_errors(); }