$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Boris (monade_at_[hidden])
Date: 2007-06-08 10:39:00
Hi,
I have two predicates f1 and f2 and I want to construct the predicate 
f4 = f1 && f2 using boost::bind.
Unfortunately I observe a strange behaviour of boost::bind I can not explain.
struct Test
{
   int a;
   int b;
};
   Test t = { 1, 2 };
   typedef boost::function< bool (Test const&) > Fn;
   Fn f1 = bind( &Test::a, _1 ) == 1;
   assert (f1( t )); // Ok
   Fn f2 = bind( &Test::b, _1 ) == 3;
   assert (!f2( t )); // ok
   Fn f3 = bind( 
      std::logical_and< bool >(), 
      bind( &Test::a, _1 ) == 1, 
      bind( &Test::b, _1 ) == 3 );
   assert (!f3( t )); // Ok
   Fn f4 = bind( std::logical_and< bool >(), f1, f2 );
   assert (!f4( t )); // assertion failed 
Why does the predicate f4 behave different from f3?
Thanks,
Boris