samedi 30 juillet 2016

Can I assign/move a new value into a unique_ptr inside a tuple?

The need to do this has arisen since I want MyClass::run to use all the other tuple elements. Basically, I have a vector of these tuples to form a kind of table. I couldn't figure out myself how to properly do this. Can you help?

using namespace std;
tuple<unique_ptr<thread>, MyOtherInfo> tup = forward_as_tuple(nullptr, MyOtherInfo());
get<0>(tup) = make_unique<thread>(&MyClass::run, this, &tup);

Aucun commentaire:

Enregistrer un commentaire