Boost logo

Boost :

Subject: Re: [boost] [Iterator][MultiIndex]iterator-specificpartition_point-relatedfunctions
From: David Abrahams (dave_at_[hidden])
Date: 2008-12-25 11:04:29


on Thu Dec 25 2008, Arno Schödl <aschoedl-AT-think-cell.com> wrote:

>> Do you mean this?
>>
>> namespace boost {
>>
>> template< ... >
>> It lower_bound( It begin, It end, T value ) {
>> using boost::partition_point;
>> return partition_point( begin, end, boost::bind( ... ) );
>> }
>>
>> template< ... >
>> It partition_point( It begin, It end, Pred pred ) {
>> return std::lower_bound( begin, end, boost::bind( ... ) );
>> }
>>
>> // a custom implementation of partition_point:
>> template< ... >
>> transform_iterator<It,Func> partition_point(transform_iterator<It,Func> begin,
>> transform_iterator<It,Func> end, Pred pred ) {
>> ...
>> }
>
> Something like that, yes.

Please make an effort to use proper quoting. Thanks.

>> > Why do you think ADL is o.k. for customizing boost::partition_point (soon
>> > std::partition_point, N2666), but not for customizing std::lower_bound? AFAIK, the
>> > same arguments apply to both.
>
>> Because nobody wants to customize lower_bound, upper_bound, equal_range,
>> and binary_search when they could instead customize partition point
>> alone.
>
> The counting_iterator example above shows that people may want to, for special cases
> and not inside a library, but as an optimization for their special iterator
> implementation. It feels funny to me to use different techniques for different
> functions. And you pay the overhead of boost::bind for any call to lower_bound,
> customized or not. I am willing to do it, though, if that's what you prefer.

You don't have to use boost::bind. Just use the standard binders.

Furthermore, if you publish the type of the function object used, people
can still customize all of those individual variants if they're crazy
enough to want to do that.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk