std :: string :: max_size()作为静态成员 [英] std::string::max_size() as static member
本文介绍了std :: string :: max_size()作为静态成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 max_size
是 std :: string
的静态成员?
这是编译,但我认为它的奇怪,所有字符串的公共属性只能通过一个字符串的实例访问:
This compiles but I think its strange that a property common to all strings can only be accessed via an instance of a string:
std::size_t max_size = std::string().max_size();
为什么这样实现?
推荐答案
为什么max_size不是std :: string的静态成员?
Why isn't max_size a static member of std::string?
因为max_size返回值取决于字符串实例在内部使用的allocator实例。
Because max_size return value depends on the allocator instance that the string instance uses internally.
这篇关于std :: string :: max_size()作为静态成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文