[RISCV] Check isFixedLengthVector before calling getVectorNumElements in getSingleShu...
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.mod / nonmember_swap.pass.cpp
blob3e89e6c66bf3e0b3f1ef26bb8630dde8e14bf733
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 //===----------------------------------------------------------------------===//
9 // <mutex>
11 // template <class Mutex> class unique_lock;
13 // template <class Mutex>
14 // void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
16 #include <cassert>
17 #include <memory>
18 #include <mutex>
20 #include "checking_mutex.h"
21 #include "test_macros.h"
23 #if TEST_STD_VER >= 11
24 static_assert(noexcept(swap(std::declval<std::unique_lock<checking_mutex>&>(),
25 std::declval<std::unique_lock<checking_mutex>&>())),
26 "");
27 #endif
29 int main(int, char**) {
30 checking_mutex mux;
31 std::unique_lock<checking_mutex> lock1(mux);
32 std::unique_lock<checking_mutex> lock2;
34 swap(lock1, lock2);
36 assert(lock1.mutex() == nullptr);
37 assert(!lock1.owns_lock());
38 assert(lock2.mutex() == std::addressof(mux));
39 assert(lock2.owns_lock() == true);
41 return 0;