How to write user defined copy-constructor of a class/struct with array of atomic variables? For example the following code does not compile
struct foo
{
std::array<std::atomic_int,3> a;
foo() = default;
foo(const int& i, const int& j, const int& k):a{{i,j,k}}{}
}
for the reason that "error: declared here __atomic_base(const __atomic_base&) = delete;" i.e. this is deleted in the definition of atomic type. Had it been non atomic it would have been done.
Is there some way to do this?
I have gone through the discussions here C++ - How to initialise an array of atomics? .