Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-11-16 11:45:11


On Fri, Nov 16, 2012 at 5:00 AM, Mathias Gaunard <
mathias.gaunard_at_[hidden]> wrote:

> On 16/11/12 06:30, Jeffrey Lee Hellrung, Jr. wrote:
>
> How is this different from (say) contiguous_range< char > /
>> contiguous_range< char const > ? I can imagine a contiguous_range<T> that
>> wraps a pair of T*s, which would seem to be a simple generalization of
>> your
>> proposed string_ref.
>>
>
> It isn't.
> The only difference is that string_ref provides an interface for substring
> operations, similar to std::string but without returning copies of the
> data, hence the string in the name.
>

Nothing here sounds specific to strings other than naming. That's why it
seems like unnecessary specificity to me. IMHO, I would think

typedef contiguous_range< char > string_ref;
typedef contiguous_range< char const > string_cref;

would be better, and if you want an interface with names specifically
tailored to strings, make then free functions.

(And, no, contiguous_range does not exist in Boost, but given we already
have a model of it in the proposed string_ref, it seems like a simple
matter to provide it.)

- Jeff


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