15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier //
9*a7f9895cSLouis Dionne // UNSUPPORTED: no-threads
1031cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11
112659663eSLouis Dionne 
125a83710eSEric Fiselier // <shared_mutex>
135a83710eSEric Fiselier 
145a83710eSEric Fiselier // template <class Mutex> class shared_lock;
155a83710eSEric Fiselier 
165a83710eSEric Fiselier // explicit operator bool() const noexcept;
175a83710eSEric Fiselier 
185a83710eSEric Fiselier #include <shared_mutex>
195a83710eSEric Fiselier #include <cassert>
206cb05ca3SChristopher Di Bella #include <type_traits>
215a83710eSEric Fiselier 
227fc6a556SMarshall Clow #include "test_macros.h"
237fc6a556SMarshall Clow 
24317e92a3SArthur O'Dwyer struct M {
lock_sharedM25317e92a3SArthur O'Dwyer     void lock_shared() {}
unlock_sharedM26317e92a3SArthur O'Dwyer     void unlock_shared() {}
27317e92a3SArthur O'Dwyer };
285a83710eSEric Fiselier 
main(int,char **)292df59c50SJF Bastien int main(int, char**)
305a83710eSEric Fiselier {
31317e92a3SArthur O'Dwyer     static_assert(std::is_constructible<bool, std::shared_lock<M>>::value, "");
32317e92a3SArthur O'Dwyer     static_assert(!std::is_convertible<std::shared_lock<M>, bool>::value, "");
33317e92a3SArthur O'Dwyer 
34317e92a3SArthur O'Dwyer     M m;
35317e92a3SArthur O'Dwyer     std::shared_lock<M> lk0;
365a83710eSEric Fiselier     assert(static_cast<bool>(lk0) == false);
37317e92a3SArthur O'Dwyer     std::shared_lock<M> lk1(m);
385a83710eSEric Fiselier     assert(static_cast<bool>(lk1) == true);
395a83710eSEric Fiselier     lk1.unlock();
405a83710eSEric Fiselier     assert(static_cast<bool>(lk1) == false);
41317e92a3SArthur O'Dwyer     ASSERT_NOEXCEPT(static_cast<bool>(lk0));
422df59c50SJF Bastien 
432df59c50SJF Bastien     return 0;
445a83710eSEric Fiselier }
45