当前位置:网站首页>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
边栏推荐
猜你喜欢
最小费用最大流问题详解
Getting started with UnityShader (3) - Unity's Shader
Nuget package and upload tutorial
Resnet&API
The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%
Recommendation System - Recall Phase - 2013: DSSM (Twin Towers Model) [Embedding (Semantic Vector) Recall] [Microsoft]
LeetCode二叉树系列——226.翻转二叉树
海康摄像机取流RTSP地址规则说明
2021 OWASP TOP 10 Vulnerability Guide
The meaning of node_exporter performance monitoring information collection in Prometheus
随机推荐
The magic of SQL MERGE statement (detailed instructions)
charles进行弱网测试(app弱网测试怎么做)
MySQL [subquery]
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
大健云仓冲刺美股:增营收反减利润 京东与DCM是股东
我把问烂了的MySQL面试题总结了一下
最小费用最大流问题详解
名创优品斥资6.95亿购买创始人叶国富所持办公楼股权
TCP详解
UnityShader入门学习(二)——渲染流水线
华医网冲刺港股:5个月亏2976万 红杉与姚文彬是股东
OpenShift 4 - Customize RHACS security policies to prevent production clusters from using high-risk registry
2021 OWASP TOP 10 Vulnerability Guide
MySQL【子查询】
格林美瑞交所IPO:募资3.8亿美元 更多中国企业将赴欧洲上市
Node实现数据加密
OAuth2:单点登陆客户端
“听我说谢谢你”还能用古诗来说?清华搞了个“据意查句”神器,一键搜索你想要的名言警句...
763.划分字母区间——之打开新世界
力扣:56. 合并区间