Reputation: 553
I am creating a vector of Poco Threads like this:
using Poco::Thread;
std::vector<Thread> threads;
Thread pt;
threads.push_back(pt);
and I get the following error:
c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0(593): error C2248: 'Poco::Thread::Thread' : cannot access private member declared in class 'Poco::Thread'
What is the reason and which container should I use to store threads?
Upvotes: 0
Views: 159
Reputation: 9837
Poco::Thread
's can only be moved, not copied, and so rely on having a move constructor/move assignment operator. You are using an ancient version of Visual Studio which doesn't support proper move semantics.
You need to upgrade your visual studio to something which isn't over 5 years old
Upvotes: 1
Reputation: 357
func(){ do something }
std::thread th1(func);
std::thread th2(func);
// Move thread objects to vector
vecOfThreads.push_back(std::move(th1));
vecOfThreads.push_back(std::move(th2));
// Add a Thread object to vector
vecOfThreads.push_back(std::thread(func));
Upvotes: 0