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 // unique_lock(mutex_type& m, adopt_lock_t);
16 
17 #include <mutex>
18 #include <cassert>
19 #include "nasty_containers.h"
20 
21 #include "test_macros.h"
22 
main(int,char **)23 int main(int, char**)
24 {
25     {
26     typedef std::mutex M;
27     M m;
28     m.lock();
29     std::unique_lock<M> lk(m, std::adopt_lock);
30     assert(lk.mutex() == std::addressof(m));
31     assert(lk.owns_lock() == true);
32     }
33     {
34     typedef nasty_mutex M;
35     M m;
36     m.lock();
37     std::unique_lock<M> lk(m, std::adopt_lock);
38     assert(lk.mutex() == std::addressof(m));
39     assert(lk.owns_lock() == true);
40     }
41 
42   return 0;
43 }
44