Boost logo

Boost :

Subject: Re: [boost] [Range] make range_const/mutable_iterator<C>::type non-existent if C is non-range
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-01-06 04:21:18

Arno Schödl skrev:
> Hello,
> the attached patch makes boost::range_const/mutable_iterator<C>::type non-existent if C does not have the right typedef C::(const_)iterator. For me, this fixed a compilation error in the following situation:
> template<class Rng, class Val, class BinPred>
> typename boost::range_const_iterator<Rng>::type lower_bound(Rng const& rng,Val const& x,BinPred pred); // not taken
> template<class It, class Val, class BinPred>
> It lower_bound(It itBegin,It itEnd,Val const& x) { // taken
> return itBegin; // dummy
> }
> main() {
> std::vector<int> vecn;
> int n=6;
> lower_bound( vecn.begin(), vecn.end(), n );
> }
> The return type of the overload that is not taken is range_const_iterator< std::vector<int>::iterator >::type. With the old range_const_iterator, this typedef exists, which makes the overload compile, but evaluates to std::vector<int>::iterator::const_iterator, which does not exist and causes a compiler error. With the patch, range_const_iterator< std::vector<int>::iterator >::type already does not exist, and the compiler aborts checking this overload. I don't see a way to fix this without changing or largely reimplementing range_const_iterator, because the mere presence of the "type" typedef in the default case of range_const_iterator causes the problem.
> Any chance to get this adopted?

It seems like a reasonable problem to solve. Neil, what other solutions
did you think about?

Another question: is your fix widely portable?


Boost list run by bdawes at, gregod at, cpdaniel at, john at