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
11
12// Until we drop support for the synchronization library in C++11/14/17
13// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
14
15// <semaphore>
16
17// constexpr explicit counting_semaphore(ptrdiff_t desired);
18
19#include <semaphore>
20#include <type_traits>
21
22#include "test_macros.h"
23
24static_assert(!std::is_default_constructible<std::binary_semaphore>::value, "");
25static_assert(!std::is_default_constructible<std::counting_semaphore<>>::value, "");
26
27static_assert(!std::is_convertible<int, std::binary_semaphore>::value, "");
28static_assert(!std::is_convertible<int, std::counting_semaphore<>>::value, "");
29
30#if TEST_STD_VER > 17
31// Test constexpr-constructibility. (But not destructibility.)
32constinit std::binary_semaphore bs(1);
33constinit std::counting_semaphore<> cs(1);
34#endif
35

source code of libcxx/test/std/thread/thread.semaphore/ctor.compile.pass.cpp