fork download
  1. #include <thread>
  2.  
  3. using namespace std;
  4.  
  5. struct Image {}; // dummy
  6.  
  7. void fill(int color, const Image& image) {
  8. }
  9.  
  10. int main() {
  11. int red;
  12. Image img;
  13. #if 1
  14. thread th{
  15. [&img](int c){ fill(c, img); }, red }; // Thread verwendet img
  16. #else
  17. auto f = [&img](int c){ fill(c, img); };
  18. thread th{
  19. f, red }; // Thread verwendet img
  20. #endif
  21. th.join();
  22. }
  23.  
Runtime error #stdin #stdout 0s 2960KB
stdin
Standard input is empty
stdout
Standard output is empty