Boost logo

Boost Users :

From: jarvi (jarvi_at_[hidden])
Date: 2005-09-01 11:18:25


Hello Stuart,

Thanks for submitting a full program to try immediately.

It seem to be a bug in Lambda, the type deduction gives bool for the
type of
the first branch, and const bool& for the second. And deems that both
are convertible
to each other and claims it's ambiguous.

Best,

   Jaakko Järvi

You should get an error in the compiler,
On Sep 1, 2005, at 4:32 AM, Stuart Dootson wrote:

> Hi - I've been trying to use the if_then_else_return feature of
> Boost.Lambda, and have run into a problem using Lambda's bind with
> this feature. My minimal example (at the end of the message) fails
> when compiled with the VC7.1 command line "cl -c -EHsc -DBAD" (the
> -DBAD is to compile the non-compiling code). The error message
> (attached as err.txt) indicates that return type deduction has failed
> at some point, I guess. The compiling version of the code differs from
> the non-compiling version by assigning the bind result to a variable.
> This seems to enable correct return type deduction. No other forms
> using lambda and bind that I've tried have exhibited this problem. So,
> the question is - is this a bug in Lambda or am I doing something
> wrong?
>
> Oh, I've also tried this with gcc 3.4.2 (Mingw version) and it behaved
> the same as VC7.1.
>
> Stuart Dootson
>
> #include <boost/lambda/lambda.hpp>
> #include <boost/lambda/bind.hpp>
> #include <boost/lambda/if.hpp>
> #include <boost/function.hpp>
> using namespace boost::lambda;
>
> bool Test1(char);
>
> void Fn(char c, bool b)
> {
> bool flag;
> #if defined(BAD)
> boost::function<bool(char)> fn =
> if_then_else_return(var(b),
> bind<bool>(&Test1, _1),
> constant(false)
> )
> ;
> #else
> bool blah;
> boost::function<bool(char)> fn =
> if_then_else_return(var(b),
> var(blah)=bind(&Test1, _1),
> constant(false)
> )
> ;
> #endif
> }
> <err.txt>_______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Jaakko Järvi, Assistant Professor
-- Texas A&M University, Computer Science
-- jarvi_at_[hidden]


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