为什么这样(字符在我的实现中签名):
cout << std::is_same< char,signed char>::value;
输出错误?
最佳答案
这三种类型是在不同的时间引入的。
来自 C99 Rational:
Three types of
char
are specified:
signed
, plain, andunsigned
. A plainchar
may be represented as either signed or unsigned depending upon the implementation, as in prior practice. The typesigned char
was introduced in C89 to make available a one-byte signed integer type on those systems which implement plainchar
asunsigned char
.
它们必须在 C++ 中保持独立的类型,以允许对 char
的重载是可移植的。
关于c++ - 为什么相同的类型不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5566245/