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 12 // <mutex> 13 14 // template <class Mutex> class unique_lock; 15 16 // template <class Mutex> 17 // void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y); 18 19 #include <mutex> 20 #include <cassert> 21 22 struct mutex 23 { 24 void lock() {} 25 void unlock() {} 26 }; 27 28 mutex m; 29 30 int main() 31 { 32 std::unique_lock<mutex> lk1(m); 33 std::unique_lock<mutex> lk2; 34 swap(lk1, lk2); 35 assert(lk1.mutex() == nullptr); 36 assert(lk1.owns_lock() == false); 37 assert(lk2.mutex() == &m); 38 assert(lk2.owns_lock() == true); 39 } 40