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 #include "test_macros.h" 24 25 class G 26 { 27 int alive_; 28 public: 29 static int n_alive; 30 static bool op_run; 31 32 G() : alive_(1) {++n_alive;} 33 G(const G& g) : alive_(g.alive_) {++n_alive;} 34 ~G() {alive_ = 0; --n_alive;} 35 36 37 38 void operator()(int i, double j) 39 { 40 assert(alive_ == 1); 41 assert(n_alive >= 1); 42 assert(i == 5); 43 assert(j == 5.5); 44 op_run = true; 45 } 46 }; 47 48 int G::n_alive = 0; 49 bool G::op_run = false; 50 51 void f1() 52 { 53 std::_Exit(0); 54 } 55 56 int main(int, char**) 57 { 58 std::set_terminate(f1); 59 { 60 G g; 61 std::thread t0(g, 5, 5.5); 62 std::thread t1; 63 t0 = std::move(t1); 64 assert(false); 65 } 66 67 return 0; 68 } 69