<div dir="ltr"><div>Dear Lyberta,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 3, 2019 at 3:40 PM Lyberta <<a href="mailto:lyberta@lyberta.net">lyberta@lyberta.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Since std::c_string_view would not own the string, how do you enforce<br>
the null terminator because the user can mutate the buffer. Do you check<br>
manually in every member function and assert?<br></blockquote><div><br></div><div> 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.<br><br></div><div> 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.<br><br></div><div>Sincerely,<br></div><div>JeanHeyd<br></div></div></div>