c++ - 为什么相同的类型不同?

标签 c++ metaprogramming

为什么这样(字符在我的实现中签名):

cout << std::is_same< char,signed char>::value;

输出错误?

最佳答案

这三种类型是在不同的时间引入的。

来自 C99 Rational:

Three types of char are specified:
signed, plain, and unsigned. A plain char may be represented as either signed or unsigned depending upon the implementation, as in prior practice. The type signed char was introduced in C89 to make available a one-byte signed integer type on those systems which implement plain char as unsigned char.

它们必须在 C++ 中保持独立的类型,以允许对 char 的重载是可移植的。

关于c++ - 为什么相同的类型不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5566245/

相关文章:

c++ - 具有整数参数的模板的部分特化

c++ - 在二叉搜索树中找到一个节点的父节点

c++ - 使用模板元编程来包装 C 风格的可变参数

C++预处理器基于参数的条件扩展

c++ - OpenBSD 和 FreeBSD 上未剥离 libstdc++ 系统库

c++ - 在我的代码中执行存储过程时出现问题

c++ - 如何使用模板元编程重构此循环?

c++ - 在 C++ 中实现(类型化的)K 组合器

c++ - 这个 typedef 是什么意思,它有什么用?

c++ - 检查算术运算中的溢出条件