| 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 | // UNSUPPORTED: c++03, c++11, c++14 |
| 11 | |
| 12 | // <mutex> |
| 13 | |
| 14 | // scoped_lock |
| 15 | |
| 16 | // Make sure that the implicitly-generated CTAD works. |
| 17 | |
| 18 | #include <mutex> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | |
| 22 | int main(int, char**) { |
| 23 | std::mutex m1; |
| 24 | std::recursive_mutex m2; |
| 25 | std::recursive_timed_mutex m3; |
| 26 | { |
| 27 | std::scoped_lock lock(m1); |
| 28 | ASSERT_SAME_TYPE(decltype(lock), std::scoped_lock<std::mutex>); |
| 29 | } |
| 30 | { |
| 31 | std::scoped_lock lock(m1, m2); |
| 32 | ASSERT_SAME_TYPE(decltype(lock), std::scoped_lock<std::mutex, std::recursive_mutex>); |
| 33 | } |
| 34 | { |
| 35 | std::scoped_lock lock(m1, m2, m3); |
| 36 | ASSERT_SAME_TYPE(decltype(lock), std::scoped_lock<std::mutex, std::recursive_mutex, std::recursive_timed_mutex>); |
| 37 | } |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | |