提问者:小点点

在C++中,最大std::streamsize总是等于std::string max_size()?


此示例代码是否在所有系统上导致两个相等的值?

#include <limits>
#include <iostream>
#include <string>

int main() {
    std::cout << std::numeric_limits<std::streamsize>::max()<< '\n';
    
    std::string example;
    std::cout << example.max_size() << '\n';
}

共1个答案

匿名用户

无论在理论上还是在实践中都是绝对不能保证的。例如。在我的机器上,它会打印:

9223372036854775807
4611686018427387903

首先,它是Windows上MSYS2编写的64位GCC 10.2.0。

相关问题


MySQL Query : SELECT * FROM v9_ask_question WHERE 1=1 AND question regexp '(c++|中|std|streamsize|等于|std|string|max_size)' ORDER BY qid DESC LIMIT 20
MySQL Error : Got error 'repetition-operator operand invalid' from regexp
MySQL Errno : 1139
Message : Got error 'repetition-operator operand invalid' from regexp
Need Help?