[lambda]lambda and lexical_cast

I just wanted to transform a vector of integers into a vecotr of strings, doesn't seem to be asking much transform(ilabels.begin(), ilabels.end(), labels.begin(), lexical_cast<string>(_1)); gcc 4.0.2 doesn't like it at all /usr/include/boost/lexical_cast.hpp:144: error: 'const class boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, 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> > >' has no member named 'fail' <begin polemic, use flame retardant> Is it only me or does lambda lack orthogonality with anything else? Whenever I use lambda for anything non isomorphic to the the plain vanilla examples, the compiler goes ballistic <end polemic> Thanks Antonio

Hi, I'm not sure, but don't you need to ll_static_cast it? Something like that might help: lexical_cast <string> (ll_static_cast<uint32_t> (_1)) Again, I'm not sure, but give it a try... Kobi. On 5/25/06, Antonio Piccolboni <piccolbo@gmail.com> wrote:
I just wanted to transform a vector of integers into a vecotr of strings, doesn't seem to be asking much
transform(ilabels.begin(), ilabels.end(), labels.begin(), lexical_cast<string>(_1));
gcc 4.0.2 doesn't like it at all
/usr/include/boost/lexical_cast.hpp:144: error: 'const class boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, boost::lambda::lambda_functor<boost::lambda::placeholder<1>
, 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> > >' has no member named 'fail'
<begin polemic, use flame retardant> Is it only me or does lambda lack orthogonality with anything else? Whenever I use lambda for anything non isomorphic to the the plain vanilla examples, the compiler goes ballistic <end polemic>
Thanks
Antonio
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- - Kobi

On May 25, 2006, at 6:13 PM, Antonio Piccolboni wrote:
I just wanted to transform a vector of integers into a vecotr of strings, doesn't seem to be asking much
transform(ilabels.begin(), ilabels.end(), labels.begin(), lexical_cast<string>(_1));
gcc 4.0.2 doesn't like it at all
/usr/include/boost/lexical_cast.hpp:144: error: 'const class boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost ::lambda::bitwise_action<boost::lambda::leftshift_action>, boost::tuples::tuple<std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, 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> > >' has no member named 'fail'
<begin polemic, use flame retardant> Is it only me or does lambda lack orthogonality with anything else? Whenever I use lambda for anything non isomorphic to the the plain vanilla examples, the compiler goes ballistic <end polemic>
To make the above work, there would have to be an overload of lexical_cast function that understands what _1 is. Lambda and lexical_cast are separate libraries, which were developed in isolation of each other, and neither library has included such an overload. In the general case, it is not a realistic expectation that every function would be overloaded to accept placeholders. bind helps in many cases. Try: boost::lambda::bind(&boost::lexical_cast<std::string, int>, _1) (assuming that the value type of labels is int) Best, Jaakko
participants (3)
-
Antonio Piccolboni
-
Jaakko Järvi
-
Kobi Cohen-Arazi