std::string 一个容器

2022-01-24 00:00:00 containers c++

std::string 是标准 c++ 库中的容器类,仅限于保存 char 元素吗?

Is std::string a container class in standard c++ library, restricted to hold only char elements?

推荐答案

其实是 std::basic_string 的 typedef.std::basic_string 是专门为字符串操作设计的容器类.这个容器也可以用于宽字符(wchar_t);在这种情况下,它的 typedef 将是 wstring.

It's a typedef of std::basic_string<char>, actually. std::basic_string is a container class specifically designed for string operations. This container can be used for wide characters (wchar_t) as well; for that case its typedef would be wstring.

相关文章