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