37 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10// UNSUPPORTED: c++03, c++1111 12// <shared_mutex>13 14// template <class Mutex> class shared_lock;15 16// mutex_type *mutex() const noexcept;17 18#include <shared_mutex>19#include <cassert>20 21#include "test_macros.h"22 23std::shared_timed_mutex m;24 25int main(int, char**)26{27 std::shared_lock<std::shared_timed_mutex> lk0;28 assert(lk0.mutex() == nullptr);29 std::shared_lock<std::shared_timed_mutex> lk1(m);30 assert(lk1.mutex() == &m);31 lk1.unlock();32 assert(lk1.mutex() == &m);33 static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept");34 35 return 0;36}37