Boost logo

Boost :

Subject: Re: [boost] [utility] string_ref construction from rvalue reference to string
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2014-08-01 18:34:29

On 31/07/2014 04:53 a.m., Андрей Давыдов wrote:
> Those errors can be caught at compile time if class "basic_string_ref"
> defintion would contain lines like following:
> template<typename Allocator>
> basic_string_ref(std::basic_string<charT, traits, Allocator> &&) = delete;
> I cannot understant does it prevent any correct usage of string_ref?

I don't think this is such a good idea. Unless I'm mistaken, it would
break the typical case of calling a function taking a `string_ref` with
a temporary.

A `string_ref` does not own the contents it represents, and the only way
to use it correctly is by guaranteeing that the lifetime of the contents
extends past that of the reference. You wouldn't generally use
`string_ref`s as automatic variables or members.


Agustín K-ballo Bergé.-

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