lambda boost::array operator[] error

Hi All, Please take a look these two similar set of statements. One uses vector, the other boost::array : /**/ using std::vector; using boost::array; using std::for_each; using boost::lambda::_1; // This one compiles: typedef vector<int> Vector; Vector v(2); vector<Vector> vv(5,v); for_each( vv.begin(), vv.end(), (_1[0]=10, _1[1]=9) ); // This one doesn't: typedef array<int,2> Array; vector<Array> va(5); for_each( va.begin(), va.end(), (_1[0]=10, _1[1]=9) ); /**/ With MSVC 7.1, I get: ===== d:\boost\include\boost-1_33_1\boost\lambda\detail\operator_lambda_func_base.hpp(237): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const boost::tuples::cons<HT,TT>::stored_head_type' (or there is no acceptable conversion) with [ HT=const boost::lambda::detail::parameter_traits_<const int,const boost::lambda::detail::IF<false,const int &,const int>::RET>::type, TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type ] ====================================================== With gcc 3.4.4, I get a moderately sized novel, whose last line reads: ===== /usr/local/include/boost/lambda/detail/operator_lambda_func_base.hpp:136: error: conversion from `int' to non-scalar type `boost::lambda::detail::unspecified' requested ======================================================= This is boost version 1.33.1. What could be wrong? thx

The return type deduction mechanism of boost lambda does not recognize boost::array, and does not know what the return type of the subscription mechanism is: Try: ret<int&>(_1[0]) = 10, ret<int&>(_1[1]=9 ) (I didn't, but hopefully you get the idea). Jaakko On Sep 30, 2006, at 6:13 PM, Levent Yilmaz wrote:
Hi All,
Please take a look these two similar set of statements. One uses vector, the other boost::array :
/**/
using std::vector; using boost::array; using std::for_each; using boost::lambda::_1;
// This one compiles: typedef vector<int> Vector; Vector v(2); vector<Vector> vv(5,v); for_each( vv.begin(), vv.end(), (_1[0]=10, _1[1]=9) );
// This one doesn't: typedef array<int,2> Array; vector<Array> va(5); for_each( va.begin(), va.end(), (_1[0]=10, _1[1]=9) );
/**/
With MSVC 7.1, I get: ===== d:\boost\include\boost-1_33_1\boost\lambda\detail \operator_lambda_func_base.hpp(237): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const boost::tuples::cons<HT,TT>::stored_head_type' (or there is no acceptable conversion) with [ HT=const boost::lambda::detail::parameter_traits_<const int,const boost::lambda::detail::IF<false,const int &,const int>::RET>::type,
TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,b oost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_t ype,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::n ull_type,boost::tuples::null_type,boost::tuples::null_type,boost::tupl es::null_type>::type ] ======================================================
With gcc 3.4.4, I get a moderately sized novel, whose last line reads: ===== /usr/local/include/boost/lambda/detail/ operator_lambda_func_base.hpp:136: error: conversion from `int' to non-scalar type `boost::lambda::detail::unspecified' requested =======================================================
This is boost version 1.33.1. What could be wrong?
thx
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Jaakko Järvi
-
Levent Yilmaz