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 // UNSUPPORTED: no-threads 10 11 // <mutex> 12 13 // template <class Mutex> class unique_lock; 14 15 // template <class Mutex> 16 // void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y); 17 18 #include <mutex> 19 #include <cassert> 20 21 #include "test_macros.h" 22 23 struct mutex 24 { lockmutex25 void lock() {} unlockmutex26 void unlock() {} 27 }; 28 29 mutex m; 30 main(int,char **)31int main(int, char**) 32 { 33 std::unique_lock<mutex> lk1(m); 34 std::unique_lock<mutex> lk2; 35 swap(lk1, lk2); 36 assert(lk1.mutex() == nullptr); 37 assert(lk1.owns_lock() == false); 38 assert(lk2.mutex() == &m); 39 assert(lk2.owns_lock() == true); 40 41 return 0; 42 } 43