Boost logo

Boost :

Subject: Re: [boost] Iterator Range and operator==
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-04-21 10:27:06


On Sat, Apr 21, 2012 at 4:07 PM, Dave Abrahams <dave_at_[hidden]> wrote:
>
> on Sat Apr 21 2012, Olaf van der Spek <ml-AT-vdspek.org> wrote:
>
>> On Sat, Apr 21, 2012 at 11:33 AM, Dave Abrahams <dave_at_[hidden]> wrote:
>>>> It is current behaviour. But is it expected behaviour?
>>>
>>> Yes.
>>
>> Based on what? Knowledge of this issue?
>
> Yes.  The range library originally treated char* as null-terminated, and there
> was an outcry.

I know, but what do you think the average C++ dev is expecting?
IMO it's understandable (once you know about the issue), but not expected.

>>> Until the language gives us a way to distinguish string literals
>>> from other arbitrary arrays of char, it's the best we can do.  The
>>> alternative is to have generic code suddenly stop working when T==char.
>>
>> What about requiring the use of as_array or as_literal in all cases?
>
> You mean, so that raw built-in arrays would cease to be ranges at all?
> I guess that's a possiblity.  Nobody thought about that, IIRC.

Yes.
If necessary just for char[] to minimize breakage.

-- 
Olaf

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