什么是STL字符串限制?

Som*_*ser 5 c++ string

C++中标准模板库的字符串限制是什么?

Ale*_*x B 19

#include <iostream>
#include <string>

int main() {
    std::cout << std::string().max_size() << std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

  • 是的,有趣的是`std :: string :: allocator_type().max_size()`给出了一个不同的(更大的)答案.不知道为什么会这样.. (2认同)