Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-11-17 18:49:46

On 17/11/12 23:34, Andrey Semashev wrote:

> There is no way to safely detect a string literal, so unless you want to
> strlen it anyway the construction has to be explicit.

There is no need to detect anything.

string_ref is defined like so

string_ref::string_ref(const char* s) : ptr(s), size(strlen(s)) {}

And it's like this by design.

string_ref doesn't even have construction from an arbitrary range in
N3334. But if it were to be added, the behaviour wrt string literals
would need to stay the same.

The fact that you can't tell apart an array from a string literal using
types is irrelevant.

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