|
Boost Users : |
From: Dizzy (dizzy_at_[hidden])
Date: 2007-03-29 11:05:12
Hello
On Thursday 29 March 2007 17:42, Nat Goodspeed wrote:
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Dizzy
> Sent: Thursday, March 29, 2007 5:05 AM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] [lambda] logical operators related errors
>
> #include <boost/lambda/lambda.hpp>
> #include <boost/bind.hpp>
> #include <boost/mem_fn.hpp>
>
> int main()
> {
> using boost::bind;
> using boost::mem_fn;
>
> A a1("str1", "str2", "str3");
> A a2("str2", "str1", "str3");
>
> eval(((bind(&A::s1, _1) < bind(&A::s1, _2)) && (bind(&A::s2, _1)
> <
> bind(&A::s2, _2)))(a1, a2));
> }
>
> This errors compiling about operator&& no match found.
>
> [Nat] I think the problem may be that you're mixing boost::bind with
> plain operators. Try using boost::lambda::bind instead and see if you
> get farther.
Ok, using lambda::bind and lambda::_1, lambda::_2 it seems to work. However, I
thought that boost::bind since 1.33 version returns a functor that can be
used for lambda composition and it's overloaded operators (please excuse me
if I just said something stupid, I'm a beginner with all this lambda/bind
terms), hence would have explained to me why operator< did work with
boost::bind without requiring boost::lambda::bind such as operator&& seems to
require.
Any idea why operator< works with the boost::bind functors and operator&&
doesn't ? Or something else that I'm missing (such as there have been made
special overloads for operator< to work with boost::bind functors).
Thanks!
-- Mihai RUSU Email: dizzy_at_[hidden] GPG : http://dizzy.roedu.net/dizzy-gpg.txt WWW: http://dizzy.roedu.net "Linux is obsolete" -- AST
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