fork download
  1. struct Bar
  2. {
  3. void bar() {}
  4. };
  5.  
  6. struct Foo
  7. {
  8. void foo(Bar& b){ b.bar(); }
  9. };
  10.  
  11. #include <thread>
  12.  
  13. int main()
  14. {
  15. Foo f;
  16. Bar b;
  17. std::thread t(&Foo::foo, &f, std::ref(b));
  18. t.join();
  19. }
  20.  
Runtime error #stdin #stdout #stderr 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted