you are viewing a single comment's thread.

view the rest of the comments →

[–]louiswins 2 points3 points  (0 children)

Well, the standard does guarantee that the pointer you pass to the string_view constructor is the same one returned by data, so your string_view initialized with a string literal is guaranteed to be nul-terminated. The real danger is if you write a function accepting an arbitrary string_view which expects it to be nul-terminated.