Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-11-27 01:22:56

On Tue, Nov 27, 2012 at 9:48 AM, Jeffrey Lee Hellrung, Jr.
<jeffrey.hellrung_at_[hidden]> wrote:
> On Mon, Nov 26, 2012 at 7:03 PM, Yanchenko Maxim
> <maximyanchenko_at_[hidden]>wrote:
>> Consider a vector of pointers, for example. You don't want to implicitly
>> put a pointer managed by a smart pointer there, you want it to be explicit
>> so it's visible and you don't forget putting reset/release near a
>> push_back. Same applies to a vector of string_ref - you want to be sure
>> that the string referred by it lives as long a needed, and there is no
>> other way except explicit construction.
> I was under the impression that string_ref's proposed purpose was to
> provide a generic concrete (i.e., non-template) interface for string
> algorithms (both as parameters and results), and for this purpose, the
> above arguments seem irrelevant. The lifetime concerns are no worse than
> for a std::string const &.

+1, string_ref by definition doesn't own the referred characters. Its
presence is enough indication that the storage of the characters has
to be managed elsewhere. And from the user's perspective it should be
as transparent as possible.

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