I want to maintain a container (list or vector) of objects that have atomics as member variables. It seems to be creating compile errors I am not sure how to fix. The messages I see are deleted copy constructor for atomics. How can I work around that? I will need to add to the list (or vector)
#include <atomic>
#include <list>
struct S {
std::atomic<int> n_{0};
};
int main() {
std::list<S> l1;
std::list<S> l2 = l1; // compile error
std::list<std::shared_ptr<S>> l;
S s1;
auto ss1 = std::make_shared<S>(s1); // compile error
}
();` and have it construct it directly into the shared pointer?– ShadowRanger Oct 10 '22 at 22:40