blob: d079d2d8b03a7901a69d2a275c83ca7f9d32d02d [file] [log] [blame]
Howard Hinnantba898e42013-09-21 01:49:28 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Jonathan Roelofs8d86b2e2014-09-05 19:45:05 +00009//
10// UNSUPPORTED: libcpp-has-no-threads
Howard Hinnantba898e42013-09-21 01:49:28 +000011
12// <shared_mutex>
13
14// template <class Mutex> class shared_lock;
15
16// explicit operator bool() const noexcept;
17
18#include <shared_mutex>
19#include <cassert>
20
Dan Albert1d4a1ed2016-05-25 22:36:09 -070021#if _LIBCPP_STD_VER > 11
22
David Majnemerf9f95be2014-03-17 20:19:44 +000023std::shared_timed_mutex m;
Howard Hinnantba898e42013-09-21 01:49:28 +000024
Dan Albert1d4a1ed2016-05-25 22:36:09 -070025#endif // _LIBCPP_STD_VER > 11
26
Howard Hinnantba898e42013-09-21 01:49:28 +000027int main()
28{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070029#if _LIBCPP_STD_VER > 11
David Majnemerf9f95be2014-03-17 20:19:44 +000030 std::shared_lock<std::shared_timed_mutex> lk0;
Howard Hinnantba898e42013-09-21 01:49:28 +000031 assert(static_cast<bool>(lk0) == false);
David Majnemerf9f95be2014-03-17 20:19:44 +000032 std::shared_lock<std::shared_timed_mutex> lk1(m);
Howard Hinnantba898e42013-09-21 01:49:28 +000033 assert(static_cast<bool>(lk1) == true);
34 lk1.unlock();
35 assert(static_cast<bool>(lk1) == false);
36 static_assert(noexcept(static_cast<bool>(lk0)), "explicit operator bool() must be noexcept");
Dan Albert1d4a1ed2016-05-25 22:36:09 -070037#endif // _LIBCPP_STD_VER > 11
Howard Hinnantba898e42013-09-21 01:49:28 +000038}