lundi 5 janvier 2015

I was going through some problems with my atomic container and saw this link .


Is there a reason why std::atomic isn't copy-constructable? The solution seems to be this where they just pass the T value to the non-atomic constructor with the atomic load function (if I'm not mistaken).


So in general, is this copy constructor thread safe?



template<typename T>
struct MobileAtomic
{
std::atomic<T> atomic;

explicit MobileAtomic ( std::atomic<T> const& a ) : atomic ( a.load() ) {}

};

Aucun commentaire:

Enregistrer un commentaire