+ 2

RAII for Thread | Movable thread

Hi I have implemented RAII for thread using thread object as reference like thread& t in attached code. I know thread cannot be copied but can be moved. Is it possible to implement by any chance with RAII class have member as thread t? Basically, I want to move constructor argument thread to member variable thread t from move constructor, but it is not working. Like below: thread t; myThread(myThread&& t) noexcept : t(move(t)) {} Feel free to ask for any query. https://code.sololearn.com/cjKMg2Pdjapx/?ref=app

24th Dec 2022, 4:11 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Réponses
+ 1
Did you want something like this? https://code.sololearn.com/c49la3Tzh3cU/?ref=app
1st Jan 2023, 11:39 AM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
0
Thanks Volodymyr Chelnokov perfect..exactly what I was looking for
3rd Jan 2023, 4:03 AM
Ketan Lalcheta
Ketan Lalcheta - avatar