Boost logo

Boost Users :

From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2005-09-01 04:32:30


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
}




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