Does std::atomic<basic_type>
guarantee the value of basic_type
to be 0 / 0.0 (whichever is applicable) when created as a class member without being explicitely initialized for:
?
Example:
class Foo
{
public:
std::atomic<int> bar;
};
int main()
{
Foo foo;
return foo.bar; //foo.bar guaranteed to be 0?
}
from cppreference documentation of std::atomic default constructor:
The default constructor is trivial: no initialization takes place other than zero initialization of static and thread-local objects. std::atomic_init may be used to complete initialization.
Hence in your case you will have the same guarantees as if you had declared simply int bar;