Skip to content
败犬日报 2025-11-09

败犬日报 2025-11-09

1. std::string 是管理长度 + 数据还是末尾加 \0

都是。

另外 string_view 不保证末尾有 \0

2. string_view 可以用来读写吗

读可以,写不推荐。因为 string_view 设计上就是只读的,例如 operator[] 只返回 const 引用。

推荐用 std::span<char> (C++20) 来写。