1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // UNSUPPORTED: libcpp-has-no-threads 11 // UNSUPPORTED: c++98, c++03 12 13 // <thread> 14 15 // class thread 16 17 // thread& operator=(thread&& t); 18 19 #include <thread> 20 #include <exception> 21 #include <cstdlib> 22 #include <cassert> 23 24 class G 25 { 26 int alive_; 27 public: 28 static int n_alive; 29 static bool op_run; 30 31 G() : alive_(1) {++n_alive;} 32 G(const G& g) : alive_(g.alive_) {++n_alive;} 33 ~G() {alive_ = 0; --n_alive;} 34 35 36 37 void operator()(int i, double j) 38 { 39 assert(alive_ == 1); 40 assert(n_alive >= 1); 41 assert(i == 5); 42 assert(j == 5.5); 43 op_run = true; 44 } 45 }; 46 47 int G::n_alive = 0; 48 bool G::op_run = false; 49 50 void f1() 51 { 52 std::_Exit(0); 53 } 54 55 int main() 56 { 57 std::set_terminate(f1); 58 { 59 G g; 60 std::thread t0(g, 5, 5.5); 61 std::thread::id id = t0.get_id(); 62 std::thread t1; 63 t0 = std::move(t1); 64 assert(false); 65 } 66 } 67