$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [Iterator][MultiIndex]iterator-specificpartition_point-related functions
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2008-11-27 16:14:17
Arno Schödl wrote:
> 
> So here is the implementation, as it is running in our production code. As
> far as I can see, there is no boost::partition_point, so I rolled my own.
> The code is only half-boostified. Ignore the make_XXX_range functions.
> BOOST_CUSTOM_PARTITION is currently a macro, because IMO that is the only
> way to be able to add it to existing iterators. If Boost.Iterator and
> Boost.MultiIndex are both willing to include it into their iterators, I am
> happy to make it a base class a la iterator_facade and integrate it into
> the existing code base.
> 
Hi Arno, I've had a look at your code and am a bit puzzled about some
details:
Your BOOST_CUSTOM_PARTITION macro overloads lower_bound, etc
for the iterator type of interest: as far as I can see, this is not
necessary
since boost::lower_bound could use partition_point through ADL, which is
the only customization point we need. To put it more succintly,
why can't you just have
namespace boost{
template<typename _It,typename Val,typenameBinPred>
_It lower_bound(_It itBegin,_It itEnd,const Val &x,BinPred pred){
  using namespace boost;
  return partition_point(itBegin,itEnd,!boost::bind(pred,_1,x)); // ADL used
}   
}
and let users overload partition_point when needed?
template<typename FilterPred,typename It,typename UnaryPred>
filter_iterator<FilterPred,It> partition_point(
  filter_iterator<FilterPred,It> itBegin,
  filter_iterator<FilterPred,It> itEnd,
  UnaryPred pred ){
  using namespace boost;
  return make_filter_iterator(
    itBegin.predicate(),
    partition_point(
      itBegin.base(),
      itEnd.base(),
      pred
    ),
    itBegin.end()
  );
}
This would't have to use fancy overloading macros or base classes,
and it covers all the use cases your current scaffolding does.
JoaquÃn M López Muñoz
Telefónica, Investigación y Desarrollo
-- View this message in context: http://www.nabble.com/-MultiIndex--STL-algorithm-support-for-multi_index_containers-tp20406458p20725686.html Sent from the Boost - Dev mailing list archive at Nabble.com.