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 // <thread> 10 11 // class thread 12 13 // thread& operator=(thread&& t); 14 15 #include <thread> 16 #include <new> 17 #include <cstdlib> 18 #include <cassert> 19 20 class G 21 { 22 int alive_; 23 public: 24 static int n_alive; 25 static bool op_run; 26 27 G() : alive_(1) {++n_alive;} 28 G(const G& g) : alive_(g.alive_) {++n_alive;} 29 ~G() {alive_ = 0; --n_alive;} 30 31 void operator()() 32 { 33 assert(alive_ == 1); 34 assert(n_alive >= 1); 35 op_run = true; 36 } 37 38 }; 39 40 int G::n_alive = 0; 41 bool G::op_run = false; 42 43 int main(int, char**) 44 { 45 { 46 std::thread t0(G()); 47 std::thread t1; 48 t1 = t0; 49 } 50 51 return 0; 52 } 53