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 // void swap(unique_lock& u); 15 16 #include <mutex> 17 #include <cassert> 18 19 struct mutex 20 { lockmutex21 void lock() {} unlockmutex22 void unlock() {} 23 }; 24 25 mutex m; 26 main()27int main() 28 { 29 std::unique_lock<mutex> lk1(m); 30 std::unique_lock<mutex> lk2; 31 lk1.swap(lk2); 32 assert(lk1.mutex() == nullptr); 33 assert(lk1.owns_lock() == false); 34 assert(lk2.mutex() == &m); 35 assert(lk2.owns_lock() == true); 36 } 37