当作为类成员创建时,std::atomic<basic_type>
保证值为0 / 0.0(以适用者为准),而无需显式初始化:basic_type
- int / uint / short / ushort / 等等...
- 和; 浮动/双
?
例子:
class Foo
{
public:
std::atomic<int> bar;
};
int main()
{
Foo foo;
return foo.bar; //foo.bar guaranteed to be 0?
}