[SG16-Unicode] SG16 approval for LEWG to review std::filesystem::path_view

JeanHeyd Meneide phdofthehouse at gmail.com
Wed Jul 3 22:14:16 CEST 2019


Dear Lyberta,

On Wed, Jul 3, 2019 at 3:40 PM Lyberta <lyberta at lyberta.net> wrote:

> Since std::c_string_view would not own the string, how do you enforce
> the null terminator because the user can mutate the buffer. Do you check
> manually in every member function and assert?
>

      The plan would be with an assert() on construction, at the very
least, or a contract check on both the constructor and the .c_str()
methods. That would seem like a reasonable compromise. Even if it's not
strictly enforceable, it's infinitely better than `const CharT*` + size
because it tells the user -- semantically -- what is expected, without
having to read the specification / standard.

      Really, my only qualm with demanding const CharT* and
basic_string_view<X>'s be null terminated is that there's no way to know.
Some APIs require it, some don't, and there's no way to tell without
carefully thumbing through the docs. It's not a good user experience: even
if c_string_view did nothing but privately derive from string_view and
forward all methods, that'd still be an immense improvement because at
least somewhere it's documented.

Sincerely,
JeanHeyd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/unicode/attachments/20190703/86759d1e/attachment.html 


More information about the Unicode mailing list