1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // UNSUPPORTED: libcpp-has-no-threads 10 // UNSUPPORTED: c++98, c++03 11 12 // <thread> 13 14 // class thread 15 16 // thread& operator=(thread&& t); 17 18 #include <thread> 19 #include <exception> 20 #include <cstdlib> 21 #include <cassert> 22 23 class G 24 { 25 int alive_; 26 public: 27 static int n_alive; 28 static bool op_run; 29 30 G() : alive_(1) {++n_alive;} 31 G(const G& g) : alive_(g.alive_) {++n_alive;} 32 ~G() {alive_ = 0; --n_alive;} 33 34 35 36 void operator()(int i, double j) 37 { 38 assert(alive_ == 1); 39 assert(n_alive >= 1); 40 assert(i == 5); 41 assert(j == 5.5); 42 op_run = true; 43 } 44 }; 45 46 int G::n_alive = 0; 47 bool G::op_run = false; 48 49 void f1() 50 { 51 std::_Exit(0); 52 } 53 54 int main(int, char**) 55 { 56 std::set_terminate(f1); 57 { 58 G g; 59 std::thread t0(g, 5, 5.5); 60 std::thread t1; 61 t0 = std::move(t1); 62 assert(false); 63 } 64 65 return 0; 66 } 67