| 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 | // <mutex> |
| 10 | |
| 11 | // template <class Mutex> class unique_lock; |
| 12 | |
| 13 | // unique_lock& operator=(unique_lock&& u); |
| 14 | |
| 15 | #include <cassert> |
| 16 | #include <memory> |
| 17 | #include <mutex> |
| 18 | |
| 19 | #include "checking_mutex.h" |
| 20 | |
| 21 | int main(int, char**) { |
| 22 | checking_mutex m0; |
| 23 | checking_mutex m1; |
| 24 | std::unique_lock<checking_mutex> lk0(m0); |
| 25 | std::unique_lock<checking_mutex> lk1(m1); |
| 26 | |
| 27 | auto& result = (lk1 = std::move(lk0)); |
| 28 | |
| 29 | assert(&result == &lk1); |
| 30 | assert(lk1.mutex() == std::addressof(m0)); |
| 31 | assert(lk1.owns_lock()); |
| 32 | assert(lk0.mutex() == nullptr); |
| 33 | assert(!lk0.owns_lock()); |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |