|
Boost : |
Subject: Re: [boost] [range] Should ranges really propagate constess to the data ?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-07-23 13:23:51
On Sat, Jul 23, 2011 at 10:13 AM, Mathias Gaunard <
mathias.gaunard_at_[hidden]> wrote:
> On 07/23/2011 05:13 PM, Dave Abrahams wrote:
>
>>
>> on Fri Jul 22 2011, Samuel Debionne<debionne-AT-**hydrowide.com> wrote:
>>
>> Hello everyone,
>>> Here is an example code that motivates my question :
>>>
>>
>> <snip>
>>
>> Well, if we want something like std::vector to be a Range, then we have
>> to accept that at least *some* Ranges do propagate constness. And I'm
>> pretty sure that we don't want other Ranges (std::pair<char*,char*>) to
>> propagate constness. So unless the documentation says otherwise, I
>> would assume that the concept doesn't say anything about whether
>> constness is propagated. If you want to write generic Range code you
>> have to account for both cases.
>>
>
> Constness is propagated for containers, yes, but sub_range is not a
> container, it is a view of another range, so it should propagate the
> constness.
>
[Just to avoid confusion.]
...so it should *not* propagate the constness. Yes, I agree, but that was
explicitly the interface decision and luckily there's usually a workaround
(use boost::iterator_range).
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk