简体   繁体   English

std :: atomic_flag初始化结果

[英]std::atomic_flag initialization result

Is is really necessery to initialize std::atomic_flag in this way: 以这种方式初始化std::atomic_flag确实很std::atomic_flag

std::atomic_flag flag = ATOMIC_FLAG_INIT;

In my opinion it should have same result: 我认为应该有相同的结果:

std::atomic_flag flag;
flag.clear();

I have read all about this class from cppreference, but I am still not sure. 我已经从cppreference阅读了有关该类的所有内容,但是我仍然不确定。

According to ATOMIC_FLAG_INIT spec : 根据ATOMIC_FLAG_INIT规范

This is the only way to initialize std::atomic_flag to a definite value: the value held after any other initialization is unspecified. 这是将std :: atomic_flag初始化为确定值的唯一方法:未指定任何其他初始化之后保存的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM