Boost logo

Boost :

Subject: Re: [boost] [Range] make range_const/mutable_iterator<C>::type non-existent if C is non-range
From: Neil Groves (neil_at_[hidden])
Date: 2008-12-30 16:46:07

On Tue, Dec 30, 2008 at 6:09 PM, Arno Schödl <aschoedl_at_[hidden]>wrote:

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

I have taken some time to evaluate alternative solutions, but I think the
proposed patch is the best solution available. I am, with your permission,
going to put this into the RangeEx code in the vault. This will, if all goes
to plan, subsequently be an update of Boost.Range. It seems that this type
of solution would be applicable to the mutable and reverse variants. Do you

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

Thank you for the patch.

Neil Groves

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