Boost logo

Boost :

Subject: Re: [boost] [Iterator][MultiIndex]iterator-specificpartition_point-relatedfunctions
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2008-12-25 05:08:43


> 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.

> See http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#270
> Also, see boost/detail/binary_search.hpp, which was introduced precisely
> to work around one implementation's strict concept checking.

Ok.

> > 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.

Arno

--
Dr. Arno Schoedl · aschoedl_at_[hidden] 
Technical Director 
 
think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany 
http://www.think-cell.com · phone +49-30-666473-10 · toll-free (US) +1-800-891-8091
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Charlottenburg, HRB 85229

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