当前位置:网站首页>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
边栏推荐
- Recommendation System - Recall Phase - 2013: DSSM (Twin Towers Model) [Embedding (Semantic Vector) Recall] [Microsoft]
- Shell script classic case: backup of files
- 763.划分字母区间——之打开新世界
- sentinel与nacos持久化
- Shell project combat 1. System performance analysis
- Why do we need to sub-library and sub-table?
- LeetCode二叉树系列——110.平衡二叉树
- DeepLab Series Learning
- c语言hello world代码(代码编程入门)
- 格林美瑞交所IPO:募资3.8亿美元 更多中国企业将赴欧洲上市
猜你喜欢

Sentinel服务熔断和降级

OAuth2:微服务权限校验Session共享

搭建私有的的Nuget包服务器教程

Small test knife: Go reflection helped me convert Excel to Struct

UnityShader入门学习(二)——渲染流水线

QGIS 加载WMS数据,重新投影
![MySQL [subquery]](/img/0b/9bbf54c500d85976e6d6776b6c6f13.png)
MySQL [subquery]

名创优品斥资6.95亿购买创始人叶国富所持办公楼股权

自适应控制——仿真实验三 用超稳定性理论设计模型参考自适应系统

How to grab configuration information for DELL SC compellent storage system
随机推荐
安装Xshell并使用其进行Ymodem协议的串口传输
MySQL 23道经典面试吊打面试官
How to clean up the lodash.memoize cache in the element-plus virtual table virtual-list component?
三角恒等变换公式
Why do we need to sub-library and sub-table?
[QNX Hypervisor 2.2 User Manual] 9.13 rom
模板与泛型编程值typelist实现
为什么要分库分表?
【Pytorch】F.softmax()方法说明
How to grab configuration information for DELL SC compellent storage system
Web自动化实战——Selenium4(自动化测试环境的搭建)
c语言hello world代码(代码编程入门)
NPM淘宝镜像(最新版本)于2021-11-21 16:53:52发布新版本npm镜像[通俗易懂]
redhat/openssl生成自签ca证书并使用
ML, DL, CV common problems sorting
Spark学习(3)-Spark环境搭建-Standalone
Small test knife: Go reflection helped me convert Excel to Struct
海康摄像机取流RTSP地址规则说明
Numbers that appear only once in LeetCode
OAuth2:资源服务器