当前位置:网站首页>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 :
边栏推荐
- Linear feedback shift register (lsfr)
- [C language] file operation
- 600 English words that programmers must master
- stb_image代替其他库
- 服务器内存性能调优
- Accumulation of FPGA errors
- 【Jailhouse 文章】Virtualization over Multiprocessor System-on-Chip an Enabling Paradigm for...
- Double disk: what is a b+ tree? Do you know how b+ trees build ordered tables? What are the characteristics of b+ tree
- 判断是否为void类型
- virtualbox NAT网络模式配置
猜你喜欢

Const char* in vs2022 cannot assign char*

【C语言】文件操作

如何确定一个软件的测试结束点

向后量子密码学迁移!美国NIST公布12家合作伙伴

Event listening and deleting events - event object - default event - cancel bubbling event - event delegation - default trigger

作物叶片病害识别系统

Advantages of BGP machine room
![[HLS] Call of queuing function in pipeline simulation](/img/b2/1de129d35b0653e5ec3f985d614c4a.png)
[HLS] Call of queuing function in pipeline simulation

污水处理厂设备巡检的解决方案

VS2022中出现const char* 无法赋值 char*
随机推荐
作物叶片病害识别系统
力扣(LeetCode)203. 移除链表元素(2022.07.22)
VS2022中出现const char* 无法赋值 char*
广发期货可以开户吗?安全吗
1059 Prime Factors
600 English words that programmers must master
The pit trodden by real people tells you to avoid the 10 mistakes often made in automated testing
判断是否为void类型
Selenium.webdriver gets the result and converts it to JSON format
35岁程序员,早到的中年危机
网站建设开始前要考虑的7个问题
Advantages of BGP machine room
RNA 25. What should we do if there is only Shengxin but no experiment in SCI articles?
涅槃重生!字节大牛力荐大型分布式手册,凤凰架构让你浴火成神
券商真的有保本型理财产品吗?
Go-Excelize API源码阅读(五)—— Close()、NewSheet()
【HLS】流水线仿真之排队函数的调用
读书笔记:程序员的自我修养---第三章
污水处理厂设备巡检的解决方案
In the era of Internet of everything, see how IOT test meets the challenge of "core"