Boost logo

Boost Users :

From: Niels Aan de Brugh (nielsadb_at_[hidden])
Date: 2007-12-12 17:54:51


On Wed, Dec 12, 2007 at 08:39:41PM +0800, Guo Xu wrote:
> i found that , when
> int a = 2, b = 0
> the expression
> max( (_1 - _2 - 4)( a, b ) , 0 );
> should return 0, but return -2, why ?
> is it a bug in lambda?

The following code:

  #include <boost/lambda/lambda.hpp>
  #include <iostream>
  
  int main( int, char ** )
  {
      using namespace boost::lambda;
      int a = 2;
      int b = 0;
      std::cout << std::max( (_1 - _2 - 4 )( a, b ), 0 ) << std::endl;
  }
  
outputs 0 on my system. Using Boost 1.34.1 and GCC 4.1.2.

Check your version of std::max, and make sure it's not accidently
macroed (e.g. when including windows.h). It could be a signed/unsigned
issue.

Also, please post (a minial example of) compilable code to the mailing
list instead of code fragments.

N.


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