Boost logo

Boost :

Subject: Re: [boost] [range] Should ranges really propagate constess to the data ?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-07-22 12:16:05


On 22/07/2011 16:31, Samuel Debionne wrote:

> for instance sub_range have :
>
> iterator begin() { return base::begin(); }
> *const_iterator* begin() const { return base::begin(); }
>
> and boost::begin() is :
>
> inline range_iterator<T>::type begin( T& r ) {...}
> inline range_iterator<*const* T>::type begin( const T& r ) {...}
>
> which means that I'm probably wrong. Am I missing something ?

That explains the strange problems I had when I tried using sub_range.
iterator_range does not have those problems.

But it seems to be a feature, it you look at the doc of sub_range it
says, when comparing sub_range to iterator_range,
"Moreover, the sub_range class can propagate constness since it knows
what a corresponding const_iterator is."

This is, in my opinion, a mistake.
const sub_range<T> should *not* behave like sub_range<const T>.


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