
Hi, I thought that lambda expressions of the form: (var(actual_var) = _1)(new_value) are supposed to work. Here's a small code that does not compile with boost 1.42 and gcc4.5: #include <map> #include <boost/lambda/lambda.hpp> using namespace std; void foo() { using namespace boost::lambda; typedef multimap<int, int> MP; MP mp1; MP mp2; (var(mp1) = _1)(mp2); //compile-time error here } Are standard maps special in that regard? Thanks, Andy.

AMDG On 03/18/2011 10:03 AM, Andy Venikov wrote:
Hi, I thought that lambda expressions of the form:
(var(actual_var) = _1)(new_value)
are supposed to work.
Here's a small code that does not compile with boost 1.42 and gcc4.5:
What's the error? It works for me with msvc 10 and the trunk.
#include <map> #include <boost/lambda/lambda.hpp>
using namespace std;
void foo() { using namespace boost::lambda;
typedef multimap<int, int> MP; MP mp1; MP mp2;
(var(mp1) = _1)(mp2); //compile-time error here }
Are standard maps special in that regard?
In Christ, Steven Watanabe

On 03/18/2011 01:36 PM, Steven Watanabe wrote:
What's the error? It works for me with msvc 10 and the trunk.
OK, this one is rather long. Sorry I couldn't prune since I'm not sure what's important and what's not. In file included from /usr/include/boost/lambda/lambda.hpp:22:0, from lock_prof.cpp:21: /usr/include/boost/lambda/detail/operator_lambda_func_base.hpp: In member function ‘RET boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::assignment_action>, Args>::call(A&, B&, C&, Env&) const [with RET = std::multimap<int, int>&, A = std::multimap<int, int>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, Args = boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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>]’: /usr/include/boost/lambda/detail/lambda_functors.hpp:175:50: instantiated from ‘typename inherited::sig<boost::tuples::tuple<A&>
::type boost::lambda::lambda_functor<Base>::operator()(A&) const [with A = std::multimap<int, int>, T = boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::assignment_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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> >, typename inherited::sig<boost::tuples::tuple<A&> >::type = std::multimap<int, int>&]’ lock_prof.cpp:196:24: instantiated from here /usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:237:1: error: no match for ‘operator=’ in ‘boost::lambda::detail::select [with Arg = boost::lambda::identity<std::multimap<int, int>&>, A = std::multimap<int, int>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, typename Arg::sig<boost::tuples::tuple<A&, B&, C&, Env&> >::type = std::multimap<int, int>&](((const boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >&)((const boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >*)boost::tuples::get [with int N = 0, HT = boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, TT = boost::tuples::cons<const boost::arg<1>, boost::tuples::null_type>, typename boost::tuples::access_traits<typename boost::tuples::element<N, boost::tuples::cons<HT, TT> >::type>::const_type = const boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >&](((const boost::tuples::cons<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, boost::tuples::cons<const boost::arg<1>, boost::tuples::null_type> >&)(&((const boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::assignment_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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> *)this)->boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::assignment_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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> >::args.boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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>::<anonymous>))))), ((std::multimap<int, int>&)((std::multimap<int, int>*)a)), ((const boost::tuples::null_type&)((const boost::tuples::null_type*)b)), ((const boost::tuples::null_type&)((const boost::tuples: :null_type*)c)), ((const boost::tuples::null_type&)((const boost::tuples::null_type*)env))) = boost::lambda::detail::select [with Any = const boost::arg<1>, A = std::multimap<int, int>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type](((const boost::arg<1>&)((const boost::arg<1>*)boost::tuples::get [with int N = 1, HT = boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, TT = boost::tuples::cons<const boost::arg<1>, boost::tuples::null_type>, typename boost::tuples::access_traits<typename boost::tuples::element<N, boost::tuples::cons<HT, TT> >::type>::const_type = const boost::arg<1>&](((const boost::tuples::cons<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, boost::tuples::cons<const boost::arg<1>, boost::tuples::null_type> >&)(&((const boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::assignment_action>, boost::tuples::t uple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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> >*)this)->boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::assignment_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<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> >::args.boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::identity<std::multimap<int, int>&> >, const boost::arg<1>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_t ype, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>::<anonymous>))))), ((std::multimap<int, int>&)((std::multimap<int, int>*)a)), ((const boost::tuples::null_type&)((const boost::tuples::null_type*)b)), ((const boost::tuples::null_type&)((const boost::tuples::null_type*)c)), ((const boost::tuples::null_type&)((const boost::tuples::null_type*)env)))’ /usr/include/c++/4.5/bits/stl_multimap.h:248:7: note: candidate is: std::multimap<_Key, _Tp, _Compare, _Alloc>& std::multimap<_Key, _Tp, _Compare, _Alloc>::operator=(const std::multimap<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int, _Tp = int, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, int> >, std::multimap<_Key, _Tp, _Compare, _Alloc> = std::multimap<int, int>] make: *** [lock_prof.o] Error 1

AMDG On 03/18/2011 10:42 AM, Andy Venikov wrote:
On 03/18/2011 01:36 PM, Steven Watanabe wrote:
What's the error? It works for me with msvc 10 and the trunk.
OK, this one is rather long.
Grrr. I can't reproduce this. I tried gcc 4.5.1 with Boost 1.42, and it still compiles fine. Can you provide the full compiler command line?
Sorry I couldn't prune since I'm not sure what's important and what's not.
No problem. Unfortunately, it has everything except what I need, since it's missing the types that select returns... Can you try a couple other tests? a) Does it work if you use int instead of multmap? b) What about a simple class w/ an assignment operator? c) Do the individual pieces work: MP& r1 = var(mp1)(mp2); const MP& r2 = _1(mp2): In Christ, Steven Watanabe

On 03/18/2011 02:56 PM, Steven Watanabe wrote:
AMDG
On 03/18/2011 10:42 AM, Andy Venikov wrote:
On 03/18/2011 01:36 PM, Steven Watanabe wrote:
What's the error? It works for me with msvc 10 and the trunk.
OK, this one is rather long.
Grrr. I can't reproduce this. I tried gcc 4.5.1 with Boost 1.42, and it still compiles fine. Can you provide the full compiler command line?
Sorry I couldn't prune since I'm not sure what's important and what's not.
No problem. Unfortunately, it has everything except what I need, since it's missing the types that select returns...
Can you try a couple other tests? a) Does it work if you use int instead of multmap? b) What about a simple class w/ an assignment operator? c) Do the individual pieces work: MP& r1 = var(mp1)(mp2); const MP& r2 = _1(mp2):
It's definitely got to do with our project's configuration. I just compiled the same code outside of the project and it compiles fine. I'll try to narrow down the issue and will post results. Thanks, Andy.
participants (2)
-
Andy Venikov
-
Steven Watanabe