I am new to using lambda expressions and have come across a problem I can't
seem to resolve - would appreciate any insight on this.
The following code fails to compile with VC++ 2003:
#include "stdafx.h"
class IX {
public:
virtual double value() const = 0 ;
} ;
class X : public IX {
public:
explicit X(double value) : value_( value ) {}
virtual double value() const { return value_ ; }
private:
X() { }
double value_ ;
} ;
int _tmain(int argc, _TCHAR* argv[])
{
using namespace boost ;
using namespace boost::lambda ;
using namespace std ;
typedef boost::shared_ptr<IX> XPtr ;
XPtr x3( new X( 99 ) ) ;
XPtr x4( new X( 199 ) ) ;
std::vector<XPtr> xptrs ;
xptrs.push_back( x3 ) ;
xptrs.push_back( x4 ) ;
for_each(
xptrs.begin(),
xptrs.end(),
std::cout << bind( &IX::value, _1 )
) ;
return 0;
}
I get the following compile-time error reported and i've looked at it and
can't seem to locate the problem - if anyone could help me with this I would
appreciate it, thanks. Adrian.
COMPILATION ERROR--->>>
u:\boost\1.32.0\include\boost\lambda\detail\actions.hpp(87) : error C2665:
'boost::lambda::function_adaptor<Func>::apply' : none of the 2 overloads can
convert parameter 2 from type 'std::allocator<_Ty>::value_type'
with
[
Func=boost::lambda::return_type_N,boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::rets_t>::plain_Func
]
and
[
_Ty=XPtr
]
u:\boost\1.32.0\include\boost\lambda\detail\function_adaptors.hpp(179):
could be 'Result boost::lambda::function_adaptor<Func>::apply<RET>(Result
(__thiscall IX::* )(void) const,const Object *)'
with
[
Result=double,
Func=boost::lambda::return_type_N,boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::rets_t>::plain_Func
,
RET=boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traits
::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::type,
Object=IX
]
u:\boost\1.32.0\include\boost\lambda\detail\function_adaptors.hpp(183):
or 'Result boost::lambda::function_adaptor<Func>::apply<RET>(Result
(__thiscall IX::* )(void) const,const Object &)'
with
[
Result=double,
Func=boost::lambda::return_type_N,boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::rets_t>::plain_Func
,
RET=boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::type,
Object=IX
]
while trying to match the argument list '(const rt0 ,
std::allocator<_Ty>::value_type)'
with
[
_Ty=XPtr
]
u:\boost\1.32.0\include\boost\lambda\detail\lambda_functor_base.hpp(408)
: see reference to function template instantiation 'RET
boost::lambda::function_action<I>::apply(A1 &
,A2 &)' being compiled
with
[
RET=boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::type,
I=2,
U=const rt0,
T=IX,
A1=const rt0,
A2=std::allocator<XPtr>::value_type
]
u:\boost\1.32.0\include\boost\lambda\detail\select_functions.hpp(30)
: see reference to function template instantiation 'RET
boost::lambda::lambda_functor_base::call::sig<SigArgs>::type,A,B,C,Env>(A
&,B &,C &,Env &) const' being compiled
with
[
RET=boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>::sig>::type,
Act=boost::lambda::action<2,boost::lambda::function_action<2>>,
Args=boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type:
:type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>,
SigArgs=boost::tuples::tuple,
A=std::allocator<XPtr>::value_type,
B=const boost::tuples::null_type,
C=const boost::tuples::null_type,
Env=const boost::tuples::null_type
]
u:\boost\1.32.0\include\boost\lambda\detail\operator_lambda_func_base.hpp(212)
: see reference to function template instantiation
'boost::lambda::lambda_functor_base::sig<SigArgs>::type
boost::lambda::detail::select,A,B,C,Env>(const
boost::lambda::lambda_functor<T> &,A &,B &,C &,Env &)' being compiled
with
[
Act=boost::lambda::action<2,boost::lambda::function_action<2>>,
Args=boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>,
SigArgs=boost::
tuples::tuple,
A=std::allocator<XPtr>::value_type,
B=const boost::tuples::null_type,
C=const boost::tuples::null_type,
Env=const boost::tuples::null_type,
T=boost::lambda::lambda_functor_base>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type>>
]
u:\boost\1.32.0\include\boost\lambda\detail\lambda_functors.hpp(148)
: see reference to function template instantiation 'RET
boost::lambda::lambda_functor_base::call::sig<SigArgs>::type,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=boost::lambda::lambda_functor_baseboost::lambda::leftshift_action,boost::tuples::tuplestd::ostream::type>::RET,boost::lambda::lambda_functor>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::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>>::sig>::type,
Act=boost::lambda:
:bitwise_actionboost::lambda::leftshift_action,
Args=boost::tuples::tuplestd::ostream::type>::RET,boost::lambda::lambda_functor>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::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>,
SigArgs=boost::tuples::tuple,
A=std::allocator<XPtr>::value_type,
B=const boost::tuples::null_type,
C=const boost::tuples::null_type,
Env=const boost::tuples::null_type
]
c:\Program Files\msvs2003\Vc7\include\algorithm(21) : see reference
to function template instantiation
'boost::lambda::lambda_functor_base::sig<SigArgs>::type
boost::lambda::lambda_functor<T>::operator
()::value_type>(A &) const' being compile
d
with
[
Act=boost::lambda::bitwise_actionboost::lambda::leftshift_action,
Args=boost::tuples::tuplestd::ostream::type>::RET,boost::lambda::lambda_functor>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::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>,
SigArgs=boost::tuples::tuple,
T=boost::lambda::lambda_functor_baseboost::lambda::leftshift_action,boost::tuples::tuplestd::ostream::type>::RET,boost::lambda::lambda_functor>,boost::tuples::tuple::type,const
boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::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=XPtr,
A=std::allocator<XPtr>::value_type
]
c:\development\lambdaSpike\lambdaSpike.cpp(56) : see reference to
function template instantiation '_Fn1
std::for_each::iterator,boost::lambda::lambda_functor<T>>(_InIt,_InIt,_Fn1)'
being compiled
with
[
_Fn1=boost::lambda::lambda_functorboost::lambda::leftshift_action,boost::tuples::tuplestd::ostream::type>::RET,boost::lambda::lambda_functor>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_tr
aitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::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=XPtr,
T=boost::lambda::lambda_functor_baseboost::lambda::leftshift_action,boost::tuples::tuplestd::ostream::type>::RET,boost::lambda::lambda_functor>,boost::tuples::tuple::type,const boost::lambda::detail::bind_traits<const
boost::lambda::placeholder1_type>::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::type,boost::lambda::detail::bind_traitsboost::tuples::null_type::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<XPtr>::iterator
]
Build Time 0:01
Build log was saved at
"file://c:\development\lambdaSpike\Debug\BuildLog.htm"
lambdaSpike - 1 error(s), 0 warning(s)