fork(1) download
  1. #include <iostream>
  2. #include <future>
  3. #include <string>
  4.  
  5. class MyThread {
  6.  
  7. std::future<void> future;
  8.  
  9. public:
  10.  
  11. template<class... Args>
  12. MyThread(Args&&... myArgs) :
  13. future(std::async(std::launch::async, &MyThread::run<Args&&...>, this, std::forward<Args>(myArgs)...))
  14. {}
  15.  
  16. template<class... Args>
  17. void run(Args&&... myArgs) {}
  18. };
  19.  
  20. int main() {
  21. std::string x;
  22. MyThread thread(std::ref(x));
  23. return 0;
  24. }
Success #stdin #stdout 0s 5524KB
stdin
Standard input is empty
stdout
Standard output is empty