
Robert Jones:
I guess I could write something like
boost::function< bool( int ) > exceed_detail = _1 > max || _1 < min; boost::function< bool( size_t, size_t ) > exceeds_range = bind( exceeds_detail, bind( element, _1, _2 ) );
but it seems to introduce additional arbitrary artifacts which is not ideal, and obscures the logic to my mind.
I admit that the workarounds aren't pretty. In this case you could've written exceeds_range = bind( protect( _1 > max || _1 < min ), bind( element, _1, _2 ) ); The protect is needed because lambda::bind evaluates its first argument (boost::bind does not). In general you can introduce a local _3 via: exceeds_range_impl = ( _3 = bind( element, _1, _2 ), _3 > max || _3 < min ); exceeds_range = boost::bind( exceeds_range_impl, _1, _2, 0 ); but... one'd rather write the function by hand and be done with it. :-)