Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-02-15 13:45:14


Marshall Clow:

> At 8:12 PM +0100 2/14/08, Jean-Pierre Bergamin wrote:
>>Hello everyone
>>
>>Is there a reason why boost::bind does not overload the logical operators
>>||
>>and &&? They definitively would come in more handy to build up complicated
>>logical expressions than using the std::logical_and and std::logical_or
>>function objects.
>
> My guess is that since boost::bind could not replicate the behavior
> of && and ||, the authors decided not to provide them.
>
> The built in && will not evaluate the second argument if the first is
> false.
> Similarly, the built in || will not evalulate the second argument if
> the first is true.

You are absolutely right. I couldn't think of an elegant way to replicate
the behavior of the built-in logical operators at the time I added support
for the rest. This thread did spark my interest though and I was able to add
&& and || to the trunk, complete with the proper short-circuit semantics.


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