c++ string::size 中的 CharT 元素是什么?

标签 c++ stdstring

来自 http://en.cppreference.com/w/cpp/string/basic_string/size

The number of CharT elements in the string.

什么是CharT元素?

最佳答案

std::basic_string 是一个类模板,定义为

template< 
    class CharT, 
    class Traits = std::char_traits<CharT>, 
    class Allocator = std::allocator<CharT>
> class basic_string;

其中 CharT 是字符串存储的字符类型。所以 std::basic_string::size 返回字符串中 CharT 元素的数量。

关于c++ string::size 中的 CharT 元素是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50681173/

相关文章:

c++ - 在特定地址存储答案

c++ - 如何让线程在 std::list 上等待一个值?

c++ - GCC 对可能有效的代码抛出 init-list-lifetime 警告?

基于 C++ 策略的设计

c++ - std::string 的共享内存给出段错误 (linux)

c++ - std::set of std::string 不等式实现

c++ - 如果在单独的方法中使用,指向指针赋值的指针不起作用

c++ - 根据标准,这个 constexpr offset_of 的定义是否正确?

c++11 - std::string::assign 与 std::string::operator=

c++ - 我们可以从 char 指针创建一个 C++ 字符串对象,其中对字符串对象的操作反射(reflect)到源 char 指针吗?