jeudi 8 juin 2017

c++11; adding class declaring std::thread to a vector

class declaration:

class cA{
private:
std::thread t;
public:
cA()=default;
};

somehere in another source file:

cA *a = new cA();
std::vector<cA> v;
v.push_back(*a);

This results in a following error at compile time: cA::cA(const cA &)': attempting to reference a deleted function

I think it might have something to do with the fact that std::thread is missing a copy constructor and that vector tries to make a copy of cA object. Anyone would be willing to explain?

Aucun commentaire:

Enregistrer un commentaire