字符序列最常见的作用是传递给某个函数供其读取。这可以通过以字符串的值、引用或C风格字符串的方式传递string参数。标准库提供了string_view,它基本就是一个(指针,长度)对,表示一个字符序列。
优点:
1.可以用于以不同方式管理的字符序列。(string、const char*、string_view)
2.对于C风格字符串实参,不会创建临时string实参。
3.可以简单地传递子串。
限制:
string_view是其字符的只读视图。