I am trying to figure out a way to get a thread out of an unordered_map in c++.
However, I am getting the std::thread::thread(const std::thread &) attempting to reference a deleted function.
Example:
#include "stdafx.h"
#include <unordered_map>
#include <thread>
class ThreadContainer
{
std::unordered_map<int, std::thread> map_;
public:
void addThread(int handle, std::thread thread)
{
map_.emplace(std::move(handle), std::move(thread));
}
std::thread getThread(int handle)
{
return map_.at(handle);
}
};
int main()
{
ThreadContainer testing;
return 0;
}
In this code example I have tried return map_.at(handle);
and return std::move(map_.at(handle);
neither of these seem to work.
How can I get the std::thread back out of this unordered_map?