|
Boost : |
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2022-05-13 18:39:37
On May 13, 2022, at 11:18 AM, Peter Dimov via Boost <boost_at_[hidden]> wrote:
>
> Marshall Clow wrote:
>> On May 13, 2022, at 10:42 AM, David Bien via Boost <boost_at_[hidden]>
>> wrote:
>>>
>>> I guess when I read the impl I think to myself: What this is missing is a
>> _length member. But then it just becomes boost::string_view.
>>>
>>> What value added is there to this impl except that it is smaller than
>> boost::string_view due to lacking a _length member?
>>
>> If youâre careful and donât do much with it, it can hand you back a null
>> terminated string.
>
> ???
>
> In what scenarios will it not give you a null-terminated string?
char arr[6] = âhello";
cstring_view csv(arr);
assert(strlen(csv.data())) == 5);
arr[5] = â!â;
assert(strlen(csv.data())) == 5); // boom
â Marshall
PS. It promises to give you a null-terminated string, but has no way to actually guarantee that.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk