Boost logo

Boost Users :

Subject: [Boost-users] Boost.Lambda, boost::lambda::detail::return_type_deduction_failure?
From: stefys (stefys_at_[hidden])
Date: 2008-12-29 16:27:08


Hello, I've been trying to use Boost.Lambda in one of my simple
applications, but I can't seem to get the following code to compile:
    for_each(vect.begin(), vect.end(), (var(str) +=
_1+constant(string(", ")) ));
Where vect is a std::vector<std::string> and str is a std::string. I
have included these headers: <boost/lambda/lambda.hpp>, <vector>,
<string>, <algorithm>.
Here is the complete error I'm getting (using MSVC2005):
c:\program
files\boost\boost_1_36_0\boost\lambda\detail\operator_lambda_func_base.hpp(225)
: error C2679: binary '+=' : no operator found which takes a right-hand
operand of type
'boost::lambda::detail::return_type_deduction_failure<<unnamed-symbol>>'
(or there is no acceptable conversion)
        with
        [
            
<unnamed-symbol>=boost::lambda::detail::return_type_2_arithmetic_phase_3<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>
        ]
        f:\microsoft visual studio 8\vc\include\xstring(890): could be
'std::basic_string<_Elem,_Traits,_Ax>
&std::basic_string<_Elem,_Traits,_Ax>::operator +=(const
std::basic_string<_Elem,_Traits,_Ax> &)'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
        f:\microsoft visual studio 8\vc\include\xstring(895): or
'std::basic_string<_Elem,_Traits,_Ax>
&std::basic_string<_Elem,_Traits,_Ax>::operator +=(const _Elem *)'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
        f:\microsoft visual studio 8\vc\include\xstring(900): or
'std::basic_string<_Elem,_Traits,_Ax>
&std::basic_string<_Elem,_Traits,_Ax>::operator +=(_Elem)'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
        while trying to match the argument list '(std::string,
boost::lambda::detail::return_type_deduction_failure<<unnamed-symbol>>)'
        with
        [
            
<unnamed-symbol>=boost::lambda::detail::return_type_2_arithmetic_phase_3<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>
        ]
        c:\program
files\boost\boost_1_36_0\boost\lambda\detail\lambda_functors.hpp(148) :
see reference to function template instantiation 'RET
boost::lambda::lambda_functor_base<Act,Args>::call<std::basic_string<_Elem,_Traits,_Ax>&,A,const
boost::tuples::null_type,const boost::tuples::null_type,const
boost::tuples::null_type>(A &,B &,C &,Env &) const' being compiled
        with
        [
            
RET=std::basic_string<char,std::char_traits<char>,std::allocator<char>> &,
            
Act=boost::lambda::arithmetic_assignment_action<boost::lambda::plus_action>,
            
Args=boost::tuples::tuple<std::basic_string<char,std::char_traits<char>,std::allocator<char>>
&,boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arithmetic_action<boost::lambda::plus_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::lambda::lambda_functor<boost::lambda::identity<const
std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>,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,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>,
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>,
            
A=std::basic_string<char,std::char_traits<char>,std::allocator<char>>,
            B=const boost::tuples::null_type,
            C=const boost::tuples::null_type,
            Env=const boost::tuples::null_type
        ]
        f:\microsoft visual studio 8\vc\include\algorithm(29) : see
reference to function template instantiation
'std::basic_string<_Elem,_Traits,_Ax>
&boost::lambda::lambda_functor<T>::operator
()<std::basic_string<_Elem,_Traits,_Ax>>(A &) const' being compiled
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>,
            
T=boost::lambda::lambda_functor_base<boost::lambda::arithmetic_assignment_action<boost::lambda::plus_action>,boost::tuples::tuple<std::basic_string<char,std::char_traits<char>,std::allocator<char>>
&,boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arithmetic_action<boost::lambda::plus_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::lambda::lambda_functor<boost::lambda::identity<const
std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>,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,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>,
            
A=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
        ]
        c:\documents and settings\stefan\my documents\visual studio
2005\projects\simple\simple\simple.cpp(22) : see reference to function
template instantiation '_Fn1
std::for_each<std::_Vector_iterator<_Ty,_Alloc>,boost::lambda::lambda_functor<T>>(_InIt,_InIt,_Fn1)'
being compiled
        with
        [
            
_Fn1=boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arithmetic_assignment_action<boost::lambda::plus_action>,boost::tuples::tuple<std::basic_string<char,std::char_traits<char>,std::allocator<char>>
&,boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arithmetic_action<boost::lambda::plus_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::lambda::lambda_functor<boost::lambda::identity<const
std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>,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,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>>,
            _Ty=std::string,
            _Alloc=std::allocator<std::string>,
            
T=boost::lambda::lambda_functor_base<boost::lambda::arithmetic_assignment_action<boost::lambda::plus_action>,boost::tuples::tuple<std::basic_string<char,std::char_traits<char>,std::allocator<char>>
&,boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arithmetic_action<boost::lambda::plus_action>,boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,boost::lambda::lambda_functor<boost::lambda::identity<const
std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>,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,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>,
            
_InIt=std::_Vector_iterator<std::string,std::allocator<std::string>>
        ]

Yours sincerely,
    Steven


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net