Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-06-01 14:17:16


Arno Schoedl wrote:

> Bind has operator! overloaded to allow convenient notting of bound
> functions. Is there a specific reason not to overload all other
> operators in a similar way, for example for defining an AND of two
> predicates f and g as boost::bind( f, _1 ) && boost::bind( g, _1 )?

Yes, there are specific reasons to not overload all operators, not all of
them showstoppers.

The reason to not overload operator+ and similar is that boost::bind does no
return type deduction; it always produces a function object with a fixed
result_type.

The reason to not overload operator||, operator&& and operator, (whose
return types are known) is that x && y, x || y and x,y are not expressible
as bind( fn, x, y ) because of the specific requirements of these operators
for evaluation order and shortcut evaluation. They are still doable, of
course. If you have a prototype implementation in mind, please do not
hesitate to show it. :-)


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