Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2012-12-11 16:47:00


On Dec 10, 2012, at 7:55 AM, Sergey Cheban <s.cheban_at_[hidden]> wrote:

> On 09.12.2012 17:13, Rob Stewart wrote:
>
>>>> - safe bool or explicit bool conversion operator
>>> I don't think this is a good idea.
>> Why not?
> This seems to be not intuitive and not so safe.

It is quite intuitive to me. true means non-null, and false means null.

> The std::string has no such operator.

Why does that matter? It's still convenient. It would be a nice addition to std::string.

>>> What about pop_back(), pop_front(), swap()?
>> string_ref isn't a container, so pop_back() and pop_front() are inappropriate. However, back(), front(), and swap() are reasonable.
> It is not a container (i.e., it does not own the content) but pop_* methods still may remove the characters from it.

They wouldn't remove characters, they would only "forget" them. The semantic is sufficiently different that I don't think I would find them intuitive.

> Btw, there also are [r]find*(), r[c]begin()/r[c]end() and compare() groups of methods in the std::basic_string.

I don't think of string_ref as so complete an analogue to string. I see such things as the purview of a substring class, though that's purely subjective.

>>> And again, I propose "substring" instead of "string_ref".
>> I also have [const_]substring classes which have a different interface, so I disagree. (There is, of course, some overlap.)
> 1. Are these classes in the Boost library and/or namespace?

No. They are my own classes which I've not proposed to Boost.

> 2. Do these classes do a different job, or they just have a different interface?

They reference a std::string and operate on a subset of the string's characters. The have special constructors and replicate most of string's interface.

___
Rob


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