Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Beman Dawes (bdawes_at_[hidden])
Date: 2012-11-15 22:13:28

On Thu, Nov 15, 2012 at 3:41 PM, Phil Endecott
<spam_from_boost_dev_at_[hidden]> wrote:
> Marshall Clow wrote:
>> I'm about to check in some new functionality into the string_algo library;
>> an implementation of string_ref.
>> A string_ref is a non-owning reference to a string. It is implemented as a
>> {pointer, length} pair, and is exceedingly useful
>> when parsing, and manipulating strings in "read-only" ways.
> I did something like this once. I called mine const_string_facade - I also
> had a mutable version - and it was a template that took an iterator pair.
> This lets you adapt something like a vector<char> into a string.

basic_string_ref doesn't template its member functions with container
or iterator parameter types, so it can't do something like adapting a
vector<char> or list<char> into a string. A range-like type
(basic_string_range?) would be better for that, handles iterator types
generically, and also would be able to handle NTCTS more efficiently.
OTOH, operations that require random access iterators can use
basic_string_ref directly, but can't use a basic_string_range type,
which typically only requires input iterators.

> BUT, I think my feeling is that this is actually taking us in the wrong
> direction: my current coding style tries to avoid the "special" features of
> std::string and prefers the things that are common to other containers, and
> std::algorithms.

Yeah, I have some similar misgivings. I'd be happier if
basic_string_ref and basic_string_range were part of the same proposal
so users got in the habit of choosing the approach that is best for
their need.


Boost list run by bdawes at, gregod at, cpdaniel at, john at