Given:
#include <map>
#include
#include
#include
#include
using namespace std;
using namespace boost;
using namespace boost::lambda;
struct s
{
int key (){return 1;}
int value(){return 2;}
};
typedef map int_map;
int_map m;
var_type::type delayed_m(var(m));
template<class F>
void execute(F f)
{
s o;
f(o);
}
Why does this work?:
int main()
{
execute
(
delayed_m[lambda::bind(&s::key, lambda::_1)] =
lambda::bind(&s::value, lambda::_1)
);
}
But this doesn’t?:
int main()
{
function key (mem_fn(&s::key )),
value(mem_fn(&s::value));
execute
(
delayed_m[key] = value //compile error instantiation backtrace leads
to here
);
}
I’m using VC7.1.
Here's the error (sorry that it's so noisy):
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\boost\lambda\detail\operator_lambda_func_base.hpp(255) :
error C2440: '=' : cannot convert from 'const
boost::tuples::cons::stored_head_type' to 'int'
with
[
HT=const boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF &,const boost::function>::RET>::type,
TT=boost::tuples::detail::map_tuple_to_consboost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,b...::type
]
No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\boost\lambda\detail\lambda_functors.hpp(153) : 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::assignment_action,boost::tuples::tupleboost::lambda::subscript_action,boost::tuples::tuple>,const boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF &,const boost::function>::RET>::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>>>,const
boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF
&,const boost::function>::RET>::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::other_actionboost::lambda::assignment_action,
Args=boost::tuples::tupleboost::lambda::subscript_action,boost::tuples::tuple>,const boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF &,const boost::function>::RET>::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>>>,const
boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF
&,const boost::function>::RET>::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=s,
B=const boost::tuples::null_type,
C=const boost::tuples::null_type,
Env=const boost::tuples::null_type
]
c:\TestApps\GeneralTests\GeneralTests.cpp(27) : see reference to
function template instantiation
'boost::lambda::lambda_functor_base::sig<SigArgs>::type
boost::lambda::lambda_functor<T>::operator ()<s>(A &) const' being
compiled
with
[
Act=boost::lambda::other_actionboost::lambda::assignment_action,
Args=boost::tuples::tupleboost::lambda::subscript_action,boost::tuples::tuple>,const boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF &,const boost::function>::RET>::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>>>,const
boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF
&,const boost::function>::RET>::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::assignment_action,boost::tuples::tupleboost::lambda::subscript_action,boost::tuples::tuple>,const boost::lambda::detail:
:parameter_traits_,const
boost::lambda::detail::IF &,const
boost::function>::RET>::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>>>,const
boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF
&,const boost::function>::RET>::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=s
]
c:\TestApps\GeneralTests\GeneralTests.cpp(47) : see reference to
function template instantiation 'void
Execute(F)' being compiled
with
[
T=boost::lambda::lambda_functor_baseboost::lambda::assignment_action,boost::tuples::tupleboost::lambda::subscript_action,boost::tuples::tuple>,const boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF &,const boost::function>::RET>::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>>>,const
boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF
&,const boost::function>::RET>::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>>,
F=boost::lambda::lambda_functorboost::lambda::assignment_action,boost::tuples::tupleboost::lambda::subscript_action,boost::tuples::tuple>,const boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF &,const boost::function>::RET>::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>>>,const
boost::lambda::detail::parameter_traits_,const boost::lambda::detail::IF
&,const boost::function>::RET>::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>>>
]