std::basic_string::max_size
size_type max_size() const; | | |
---|
返回字符串由于系统或库实现限制而能够保存的最大元素数,即std::distance(begin(), end())
最大的字符串。
参数
%280%29
返回值
最大字符数。
例外
(none) | (until C++11) |
---|---|
noexcept specification: noexcept | (since C++11) |
复杂性
常量。
例
二次
#include <iostream>
#include <string>
int main()
{
std::string s;
std::cout << "Maximum size of a string is " << s.max_size() << "\n";
}
二次
可能的产出:
二次
Maximum size of a string is 4294967294
二次
另见
sizelength | returns the number of characters (public member function) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com