| 1 | // { dg-do compile { target c++11 } } |
| 2 | // { dg-require-gthreads "" } |
| 3 | |
| 4 | // PR libstdc++/106695 |
| 5 | // Explicit copy constructor does not work for a parameter passed via std::async |
| 6 | |
| 7 | #include <future> |
| 8 | |
| 9 | struct A { |
| 10 | A() = default; |
| 11 | explicit A(const A&) = default; |
| 12 | }; |
| 13 | |
| 14 | void func(const A&) { } |
| 15 | |
| 16 | void |
| 17 | test_async() |
| 18 | { |
| 19 | (void) std::async(std::launch::async, func, A{}); |
| 20 | (void) std::async(std::launch::deferred, func, A{}); |
| 21 | (void) std::async(func, A{}); |
| 22 | } |
| 23 | |
| 24 | void |
| 25 | test_task() |
| 26 | { |
| 27 | std::packaged_task<void(const A&)> task(func); |
| 28 | task(A{}); |
| 29 | } |