1 Star 3 Fork 2

Shun/cpp_new_features

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
003_rtti_std_is_same.cpp 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
ls-Brynn 提交于 2021-07-15 20:02 +08:00 . Create 003_rtti_std_is_same.cpp
#include <iostream>
#include <type_traits>
#include <cstdint>
void print_separator()
{
std::cout << "-----\n";
}
int main()
{
std::cout << std::boolalpha;
// 一些实现定义状况
std::cout << std::is_same<int, std::int32_t>::value << '\n';
// 若 'int' 为 32 位则通常为 true
std::cout << std::is_same<int, std::int64_t>::value << '\n';
// 若使用 ILP64 数据模型则可能为 true
print_separator();
// 'float' 决非整数类型
std::cout << std::is_same<float, std::int32_t>::value << '\n'; // false
print_separator();
// 'int' 为隐式的 'signed'
std::cout << std::is_same<int, int>::value << "\n"; // true
std::cout << std::is_same<int, unsigned int>::value << "\n"; // false
std::cout << std::is_same<int, signed int>::value << "\n"; // true
print_separator();
// 不同于其他类型, 'char' 既非 'unsigned' 亦非 'signed'
std::cout << std::is_same<char, char>::value << "\n"; // true
std::cout << std::is_same<char, unsigned char>::value << "\n"; // false
std::cout << std::is_same<char, signed char>::value << "\n"; // false
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/shun_dev/cpp_new_features.git
git@gitee.com:shun_dev/cpp_new_features.git
shun_dev
cpp_new_features
cpp_new_features
main

搜索帮助

371d5123 14472233 46e8bd33 14472233