I have a class A
with a member variable _atomicVar
of type std::atomic<int>
.
#include <atomic>
class A
{
public:
A();
~A();
private:
std::atomic<int> _atomicVar;
};
If I build the project I get the following error:
error C2280: 'std::atomic<int>::atomic(const std::atomic<int> &)' : attempting to reference a deleted function
I'm mainly a C# developer so I don't know every detail of C++ (yet). I don't know where I use the copy c'tor of atomic<int>
.
I also tried to initialize _atomicVar
:
std::atomic<int> _atomicVar { 0 };
... but that didn't work.
I would expect that _atomicVar
(without an explicit initialization) would get initialized with the default value for int
.
Can you tell me why this error occurs?
Aucun commentaire:
Enregistrer un commentaire