当前位置:网站首页>Judge whether it is void type
Judge whether it is void type
2022-07-23 09:28:00 【Hair like snow ty】
c++ There is a class template in the standard library is_void , Used to judge whether a certain type is void type . stay main() Do some tests in the function :
int main()
{
cout << std::is_void<int>::value << endl;
cout << std::is_void<void>::value << endl;
system("pause");
return 0;
}
result :
that is_void How to achieve it ? Actually ,is_void It can be regarded as a value extraction template .
template<typename T>
struct TraitsVoid
{
static const int value = 0;
};
template<>
struct TraitsVoid<void>
{
static const int value = 1;
};
int main()
{
cout << TraitsVoid<int>::value << endl;
cout << TraitsVoid<void>::value << endl;
system("pause");
return 0;
}
result :
边栏推荐
- The pit trodden by real people tells you to avoid the 10 mistakes often made in automated testing
- 使用HiFlow场景连接器查看每天处于地区的疫情
- 程序员不会 jvm?骨灰级工程师:全等着被淘汰吧!这是必会技能!
- 复盘:什么是B+树?你知道B+树怎么构建有序表的吗?B+树有什么特点
- 涨薪神器
- C语言实战之猜数游戏
- 服务器托管、服务器租用、云主机各自的优势
- Amplitude limiting and deblocking filtering of botu PLC signal processing series
- General design of SQL user table
- MongoDB的CRUD操作(2)
猜你喜欢

【面试:并发篇21:多线程:活跃性】死锁、活锁、饥饿

RNA 25. What should we do if there is only Shengxin but no experiment in SCI articles?

What is the combined effect of compose and recyclerview?

一文带你了解如何用SQL处理周报数据

Software testing interview ideas, skills and methods to share, learn is to earn
How many points can you get on the latest UnionPay written test for test engineers?
![[LeetCode]剑指 Offer 61. 扑克牌中的顺子](/img/ca/1756f1c33cf9b18d0c88d46bac636e.png)
[LeetCode]剑指 Offer 61. 扑克牌中的顺子

Verilog语法基础HDL Bits训练 04

真人踩過的坑,告訴你避免自動化測試常犯的10個錯誤

TFW6524完美替代进口PT6524芯片方案简介
随机推荐
【FPGA教程案例37】通信案例7——基于FPGA的FFT,IFFT傅里叶变换和逆变换
【Jailhouse 文章】Virtualization over Multiprocessor System-on-Chip an Enabling Paradigm for...
The pit trodden by real people tells you to avoid the 10 mistakes often made in automated testing
VS2022中出现const char* 无法赋值 char*
Ascension begins with change
【C语言】文件操作
广发期货可以开户吗?安全吗
线性反馈移位寄存器(LSFR)
BCG 使用之NOTIFYICONDATA托盘
2000. reverse word prefix
【C语言】预处理详解
Program environment and pretreatment
LeetCode 练习——关于二叉树的最近公共祖先两道题
La fosse Piétinée par l'homme vous dit d'éviter les 10 erreurs courantes dans les tests automatisés
只有漂亮的才能点开
Amplitude limiting and deblocking filtering of botu PLC signal processing series
微信小程序设置背景图片不显示问题解决方法
复盘:pearson皮尔森相关系数和spearman斯皮尔曼相关系数的区别
真人踩过的坑,告诉你避免自动化测试常犯的10个错误
基于时频图的音频处理-matlab