当前位置:网站首页>thread_local 变量的析构顺序
thread_local 变量的析构顺序
2022-07-31 14:47:00 【maray】
#include <stdio.h>
class C1
{
public:
C1() {
printf("c1 cons\n"); }
~C1() {
printf("c1 des\n"); }
};
class C2
{
public:
C2() {
printf("c2 cons\n"); }
~C2() {
printf("c2 des\n"); }
};
int main(int argc, const char *argv[])
{
thread_local C1 c1;
thread_local C2 c2; // 预期 c2 后构造,先析构。因为语义上 c2 有可能依赖 c1(例如 c1 是 c2 的构造参数)
return 0;
}
输出:
[xiaochu.yh test]$g++ test.cpp --std=c++11
[xiaochu.yh test]$./a.out
c1 cons
c2 cons
c2 des
c1 des
边栏推荐
- Sentinel服务熔断和降级
- OpenShift 4 - 用 Operator 部署 Redis 集群
- LeetCode二叉树系列——110.平衡二叉树
- Small test knife: Go reflection helped me convert Excel to Struct
- The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%
- MySQL【聚合函数】
- NC | 斯坦福申小涛等开发数据可重复分析计算框架TidyMass
- 组合系列--有排列就有组合
- 什么是消息队列呢?
- Unity Shader入门精要学习——透明效果
猜你喜欢

OAuth2:四种授权方式

STM32(十)------- SPI通信

TCP详解
![Recommendation System - Recall Phase - 2013: DSSM (Twin Towers Model) [Embedding (Semantic Vector) Recall] [Microsoft]](/img/40/b567780ed2cf04f1f1336922816f86.png)
Recommendation System - Recall Phase - 2013: DSSM (Twin Towers Model) [Embedding (Semantic Vector) Recall] [Microsoft]

sentinel与nacos持久化

模板与泛型编程值typelist实现

jvm 一之 类加载器

OAuth2:单点登陆客户端

Architecture actual combat battalion module 8 message queue table structure design

学习笔记12--路径-速度分解法之局部路径搜索
随机推荐
Shell script classic case: backup of files
最小费用最大流问题详解
力扣:56. 合并区间
Web自动化实战——Selenium4(自动化测试环境的搭建)
[QNX Hypervisor 2.2 User Manual]9.14 safety
Message queue data storage MySQL table design
MANIFEST.MF文件(PDB文件)
“听我说谢谢你”还能用古诗来说?清华搞了个“据意查句”神器,一键搜索你想要的名言警句...
Shell project combat 1. System performance analysis
How to grab configuration information for DELL SC compellent storage system
STM32(十)------- SPI通信
海康摄像机取流RTSP地址规则说明
[Pytorch] torch.argmax() usage
使用 PyTorch 检测眼部疾病
OpenShift 4 - Customize RHACS security policies to prevent production clusters from using high-risk registry
2021 OWASP TOP 10 漏洞指南
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
Network cable RJ45 interface pins [easy to understand]
BigDecimal 简介,常用方法
Uniapp WeChat small application reference standard components