Boost logo

Boost :

Subject: [boost] [Range] make range_const/mutable_iterator<C>::type non-existent if C is non-range
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2008-12-30 13:09:30


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?

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